Removed hardcoded pk in view_tests.tests.test_defaults.

This commit is contained in:
Tim Graham 2019-11-05 13:38:48 -05:00 committed by Mariusz Felisiak
parent 7f61b6b039
commit 22a7a406c9
1 changed files with 7 additions and 7 deletions

View File

@ -23,21 +23,21 @@ class DefaultsTests(TestCase):
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
Author.objects.create(name='Boris') author = Author.objects.create(name='Boris')
Article.objects.create( Article.objects.create(
title='Old Article', slug='old_article', author_id=1, title='Old Article', slug='old_article', author=author,
date_created=datetime.datetime(2001, 1, 1, 21, 22, 23) date_created=datetime.datetime(2001, 1, 1, 21, 22, 23)
) )
Article.objects.create( Article.objects.create(
title='Current Article', slug='current_article', author_id=1, title='Current Article', slug='current_article', author=author,
date_created=datetime.datetime(2007, 9, 17, 21, 22, 23) date_created=datetime.datetime(2007, 9, 17, 21, 22, 23)
) )
Article.objects.create( Article.objects.create(
title='Future Article', slug='future_article', author_id=1, title='Future Article', slug='future_article', author=author,
date_created=datetime.datetime(3000, 1, 1, 21, 22, 23) date_created=datetime.datetime(3000, 1, 1, 21, 22, 23)
) )
UrlArticle.objects.create( cls.urlarticle = UrlArticle.objects.create(
title='Old Article', slug='old_article', author_id=1, title='Old Article', slug='old_article', author=author,
date_created=datetime.datetime(2001, 1, 1, 21, 22, 23) date_created=datetime.datetime(2001, 1, 1, 21, 22, 23)
) )
Site(id=1, domain='testserver', name='testserver').save() Site(id=1, domain='testserver', name='testserver').save()
@ -111,7 +111,7 @@ class DefaultsTests(TestCase):
"A model can set attributes on the get_absolute_url method" "A model can set attributes on the get_absolute_url method"
self.assertTrue(getattr(UrlArticle.get_absolute_url, 'purge', False), self.assertTrue(getattr(UrlArticle.get_absolute_url, 'purge', False),
'The attributes of the original get_absolute_url must be added.') 'The attributes of the original get_absolute_url must be added.')
article = UrlArticle.objects.get(pk=1) article = UrlArticle.objects.get(pk=self.urlarticle.pk)
self.assertTrue(getattr(article.get_absolute_url, 'purge', False), self.assertTrue(getattr(article.get_absolute_url, 'purge', False),
'The attributes of the original get_absolute_url must be added.') 'The attributes of the original get_absolute_url must be added.')