diff --git a/django_lostplaces/lostplaces/tests/models/test_link_model.py b/django_lostplaces/lostplaces/tests/models/test_link_model.py index 88fb389..601b38a 100644 --- a/django_lostplaces/lostplaces/tests/models/test_link_model.py +++ b/django_lostplaces/lostplaces/tests/models/test_link_model.py @@ -19,6 +19,18 @@ from lostplaces.tests.models import ModelTestCase class ExternalLinkTestCase(ModelTestCase): model = ExternalLink + def setup(self): + self.albumlink = ExternalLink.objects.get(id=1) + + def test_label(self): + self.assertField('label', models.CharField) + + def test_url(self): + self.assertField('url', models.URLField) + +class PhotoAlbumTestCase(ModelTestCase): + model = PhotoAlbum + @classmethod def setUpTestData(cls): user = User.objects.create_user( @@ -35,7 +47,7 @@ class ExternalLinkTestCase(ModelTestCase): longitude=7.0, description='This is just a test, do not worry' ) - place.tags.add('I a tag', 'testlocation') + place.tags.add('I am a tag', 'testlocation') place.save() PhotoAlbum.objects.create( @@ -45,20 +57,11 @@ class ExternalLinkTestCase(ModelTestCase): place=place, submitted_when=timezone.now() ) + + def setUp(self): + self.albumlink = PhotoAlbum.objects.get(id=1) + self.place = Place.objects.get(id=1) - def setup(self): - self.album_link = PhotoAlbum.objects.get(id=1) - - def test_label(self): - self.assertField('label', models.CharField) - - def test_url(self): - self.assertField('url', models.URLField) - - -class PhotoAlbumTestCase(ModelTestCase): - model = PhotoAlbum - def test_place(self): field = self.assertField('place', models.ForeignKey) self.assertEqual(field.remote_field.on_delete, models.CASCADE, @@ -73,3 +76,18 @@ class PhotoAlbumTestCase(ModelTestCase): expected_related_name ) ) + + def test_label(self): + albumlink = self.albumlink + + self.assertTrue('TestLink' in albumlink.label, + msg='Expecting albumlink.label to contain \'TestLink\' string' + ) + + def test_url(self): + albumlink = self.albumlink + + self.assertTrue('lostplaces.example.com' in albumlink.url, + msg='Expecting albumlink.url to contain \'lostplaces.example.com\' string' + ) + \ No newline at end of file