Exemple #1
0
 def test_validate_raises_error_if_invalid_arguments(self):
     field = Field(self.record, name='test')
     with self.assertRaises(FieldValidationError):
         field._validate(name='test_model', invalid_arg=1)
Exemple #2
0
 def test_validate_raises_error_if_no_argument_model(self):
     field = Field(self.record, name='test')
     with self.assertRaises(FieldValidationError):
         field._validate(id=1)
Exemple #3
0
 def test_has_name_raises_error_if_kwargs_has_no_argument_name(self):
     field = Field(self.record, name='test')
     with self.assertRaises(FieldValidationError):
         field._has_name(id=1)
Exemple #4
0
 def test_validate_is_None_if_all_arguments_are_valid(self):
     field = Field(self.record, name='test')
     result = field._validate(name='test')
     self.assertTrue(result is None)
Exemple #5
0
 def test_creating_Field_when_value_is_not_str_coverts_to_str(self):
     field = Field(self.record, name='test_name', value=1)
     self.assertEqual(field.value, '1')
Exemple #6
0
 def test_has_name_returns_None_if_kwargs_has_argument_name(self):
     field = Field(self.record, name='test')
     result = field._has_name(name='test')
     self.assertEqual(result, None)
Exemple #7
0
 def test_init_calls_validate(self, mocked_validate):
     mocked_validate.return_value = None
     Field(self.record, name='test')
     Field._validate.assert_called_with(name='test')
Exemple #8
0
 def test_creating_Field_when_no_value_is_in_attributes(self):
     field = Field(self.record, name='test_name')
     self.assertEqual(field.value, None)
Exemple #9
0
 def test_validate_raises_error_if_no_argument_model(self):
     field = Field(self.record, name='test')
     with self.assertRaises(FieldValidationError):
         field._validate(id=1)
Exemple #10
0
 def test_validate_raises_error_if_invalid_arguments(self):
     field = Field(self.record, name='test')
     with self.assertRaises(FieldValidationError):
         field._validate(name='test_model', invalid_arg=1)
Exemple #11
0
 def test_validate_is_None_if_all_arguments_are_valid(self):
     field = Field(self.record, name='test')
     result = field._validate(name='test')
     self.assertTrue(result is None)
Exemple #12
0
 def test_has_name_raises_error_if_kwargs_has_no_argument_name(self):
     field = Field(self.record, name='test')
     with self.assertRaises(FieldValidationError):
         field._has_name(id=1)
Exemple #13
0
 def test_has_name_returns_None_if_kwargs_has_argument_name(self):
     field = Field(self.record, name='test')
     result = field._has_name(name='test')
     self.assertEqual(result, None)