def test_validate_calls_validate_type_with_unicode_when_passed_a_str(self):
     with patch.object(Schema, "_validate_type") as mocked:
         data = str("a string")
         Schema._validate(str, data, [])
         mocked.assert_called_once_with(unicode, data, [])
 def test_validate_calls_validate_function_when_passed_a_function(self):
     with patch.object(Schema, "_validate_function") as mocked:
         mock_function = Mock()
         Schema._validate(mock_function, "data", [])
         mocked.assert_called_once_with(mock_function, "data", [])
 def test_validate_calls_validate_type_when_passed_a_type_schema(self):
     with patch.object(Schema, "_validate_type") as mocked:
         Schema._validate(int, 12, [])
         mocked.assert_called_once_with(int, 12, [])
         mocked.reset_mock()
         Schema._validate(float, 12.1, [])
         mocked.assert_called_once_with(float, 12.1, [])
         mocked.reset_mock()
         Schema._validate(unicode, "a string", [])
         mocked.assert_called_once_with(unicode, "a string", [])
         mocked.reset_mock()
         Schema._validate(long, 12345678901234, [])
         mocked.assert_called_once_with(long, 12345678901234, [])
         mocked.reset_mock()
         Schema._validate(bool, True, [])
         mocked.assert_called_once_with(bool, True, [])
         mocked.reset_mock()
         Schema._validate(None, None, [])
         mocked.assert_called_once_with(None, None, [])
 def test_validate_calls_validate_list_when_passed_a_list_schema(self):
     with patch.object(Schema, "_validate_list") as mocked:
         Schema._validate([], [], [])
         mocked.assert_called_once_with([], [], [])
Beispiel #5
0
 def test_validate_calls_validate_type_with_unicode_when_passed_a_str(self):
     with patch.object(Schema, "_validate_type") as mocked:
         data = str("a string")
         Schema._validate(str, data, [])
         mocked.assert_called_once_with(unicode, data, [])
Beispiel #6
0
 def test_validate_calls_validate_type_when_passed_a_type_schema(self):
     with patch.object(Schema, "_validate_type") as mocked:
         Schema._validate(int, 12, [])
         mocked.assert_called_once_with(int, 12, [])
         mocked.reset_mock()
         Schema._validate(float, 12.1, [])
         mocked.assert_called_once_with(float, 12.1, [])
         mocked.reset_mock()
         Schema._validate(unicode, "a string", [])
         mocked.assert_called_once_with(unicode, "a string", [])
         mocked.reset_mock()
         Schema._validate(long, 12345678901234, [])
         mocked.assert_called_once_with(long, 12345678901234, [])
         mocked.reset_mock()
         Schema._validate(bool, True, [])
         mocked.assert_called_once_with(bool, True, [])
         mocked.reset_mock()
         Schema._validate(None, None, [])
         mocked.assert_called_once_with(None, None, [])
Beispiel #7
0
 def test_validate_calls_validate_function_when_passed_a_function(self):
     with patch.object(Schema, "_validate_function") as mocked:
         mock_function = Mock()
         Schema._validate(mock_function, "data", [])
         mocked.assert_called_once_with(mock_function, "data", [])
Beispiel #8
0
 def test_validate_calls_validate_list_when_passed_a_list_schema(self):
     with patch.object(Schema, "_validate_list") as mocked:
         Schema._validate([], [], [])
         mocked.assert_called_once_with([], [], [])