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)
def test_validate_raises_error_if_no_argument_model(self): field = Field(self.record, name='test') with self.assertRaises(FieldValidationError): field._validate(id=1)
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)
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)
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')
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)
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')
def test_creating_Field_when_no_value_is_in_attributes(self): field = Field(self.record, name='test_name') self.assertEqual(field.value, None)