def test_must_skip_invalid_input_dict(self, sub_all_refs_mock): input = {"a": "b"} expected = {"a": "b"} handler_mock = Mock() sub = SubAction() result = sub._handle_sub_value(input, handler_mock) self.assertEqual(expected, result) handler_mock.assert_not_called() sub_all_refs_mock.assert_not_called()
def test_handle_sub_value_must_call_handler_on_array(self, sub_all_refs_mock): input = ["sub string", {"a": "b"}] expected = ["sub string", {"a": "b"}] handler_mock = Mock() sub_all_refs_mock.return_value = expected[0] sub = SubAction() result = sub._handle_sub_value(input, handler_mock) self.assertEqual(expected, result) sub_all_refs_mock.assert_called_once_with(input[0], handler_mock)
def test_handle_sub_value_must_skip_no_string(self, sub_all_refs_mock): input = [{"a":"b"}] expected = [{"a":"b"}] handler_mock = Mock() sub = SubAction() result = sub._handle_sub_value(input, handler_mock) self.assertEqual(expected, result) handler_mock.assert_not_called() sub_all_refs_mock.assert_not_called()
def test_handle_sub_value_must_call_handler_on_string(self, sub_all_refs_mock): input = "sub string" expected = "result" handler_mock = Mock() sub_all_refs_mock.return_value = expected sub = SubAction() result = sub._handle_sub_value(input, handler_mock) self.assertEqual(expected, result) sub_all_refs_mock.assert_called_once_with(input, handler_mock)
def test_handle_sub_value_must_skip_no_string(self, sub_all_refs_mock): input = [{"a": "b"}] expected = [{"a": "b"}] handler_mock = Mock() sub = SubAction() result = sub._handle_sub_value(input, handler_mock) self.assertEqual(expected, result) handler_mock.assert_not_called() sub_all_refs_mock.assert_not_called()
def test_handle_sub_value_must_call_handler_on_array( self, sub_all_refs_mock): input = ["sub string", {"a": "b"}] expected = ["sub string", {"a": "b"}] handler_mock = Mock() sub_all_refs_mock.return_value = expected[0] sub = SubAction() result = sub._handle_sub_value(input, handler_mock) self.assertEqual(expected, result) sub_all_refs_mock.assert_called_once_with(input[0], handler_mock)
def test_handle_sub_value_must_call_handler_on_string( self, sub_all_refs_mock): input = "sub string" expected = "result" handler_mock = Mock() sub_all_refs_mock.return_value = expected sub = SubAction() result = sub._handle_sub_value(input, handler_mock) self.assertEqual(expected, result) sub_all_refs_mock.assert_called_once_with(input, handler_mock)