diff --git a/lostplaces/lostplaces_app/tests/models/__init__.py b/lostplaces/lostplaces_app/tests/models/__init__.py index bf88c54..f2045e5 100644 --- a/lostplaces/lostplaces_app/tests/models/__init__.py +++ b/lostplaces/lostplaces_app/tests/models/__init__.py @@ -17,7 +17,7 @@ class ModelTestCase: self.object = self.model.objects.get(id=1) self.model_name = self.model.__name__ - def _test_field(self, field_name, field_class, must_have={}, must_not_have={}): + def assertField(self, field_name, field_class, must_have={}, must_not_have={}): ''' Tests if a field exists under the given name and if the field is of the right type. @@ -89,7 +89,7 @@ class ModelTestCase: Tests if the given field is a char field and if its max_length is in min_length and max_legth ''' - field = self._test_field( + field = self.assertField( field_name, models.CharField, must_have, must_hot_have) self.assertTrue( field.max_length in range(min_length, max_length), @@ -110,7 +110,7 @@ class ModelTestCase: [MinValueValidator] if only min_value is passed, [MaxValueValidator] if only max_value is passed ''' - field = self._test_field( + field = self.assertField( field_name, models.FloatField, must_have, must_hot_have) if min_value: self.assertTrue( @@ -156,14 +156,14 @@ class SubmittableTestCase(ModelTestCase): nullable = False def test_submitted_when(self): - submitted_when = self._test_field( + submitted_when = self.assertField( 'submitted_when', models.DateTimeField, must_have={'auto_now_add': True} ) def test_submitted_by(self): - submitted_by = self._test_field('submitted_by', models.ForeignKey) + submitted_by = self.assertField('submitted_by', models.ForeignKey) if self.related_name: self.assertEqual( submitted_by.remote_field.related_name, self.related_name) diff --git a/lostplaces/lostplaces_app/tests/models/test_abstract_models.py b/lostplaces/lostplaces_app/tests/models/test_abstract_models.py index 802541f..19afcb0 100644 --- a/lostplaces/lostplaces_app/tests/models/test_abstract_models.py +++ b/lostplaces/lostplaces_app/tests/models/test_abstract_models.py @@ -15,7 +15,7 @@ class TaggableTestCase(ModelTestCase, TestCase): model = Taggable def test_tags(self): - self._test_field('tags', TaggableManager) + self.assertField('tags', TaggableManager) class MapablePointTestCase(ModelTestCase, TestCase): diff --git a/lostplaces/lostplaces_app/tests/models/test_place_image_model.py b/lostplaces/lostplaces_app/tests/models/test_place_image_model.py index bd3f4b2..1c198c3 100644 --- a/lostplaces/lostplaces_app/tests/models/test_place_image_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_place_image_model.py @@ -60,13 +60,13 @@ class TestPlaceImage(SubmittableTestCase, TestCase): ) def test_description(self): - self._test_field('description', models.TextField) + self.assertField('description', models.TextField) def test_filename(self): - self._test_field('filename',ThumbnailerImageField) + self.assertField('filename',ThumbnailerImageField) def test_place(self): - field = self._test_field('place', models.ForeignKey) + field = self.assertField('place', models.ForeignKey) self.assertEqual(field.remote_field.on_delete, models.CASCADE, msg='%s.%s deleting of %s should be cascadinf' % ( self.model_name, diff --git a/lostplaces/lostplaces_app/tests/models/test_place_model.py b/lostplaces/lostplaces_app/tests/models/test_place_model.py index e685c43..ccb6d8a 100644 --- a/lostplaces/lostplaces_app/tests/models/test_place_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_place_model.py @@ -41,7 +41,7 @@ class PlaceTestCase(SubmittableTestCase, TestCase): ) def test_decsription(self): - self._test_field('description', models.TextField) + self.assertField('description', models.TextField) def test_average_latlon(self): ''' diff --git a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py index b343f0b..76796f8 100644 --- a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py @@ -27,14 +27,14 @@ class VoucheTestCase(ModelTestCase, TestCase): ) def test_voucher_created(self): - self._test_field( + self.assertField( 'created_when', models.DateTimeField, must_have={'auto_now_add': True} ) def test_voucher_expires(self): - self._test_field( + self.assertField( 'expires_when', models.DateTimeField, must_not_have={'auto_now_add': True}