Fixed tests that rely on hardcoded id with keepdb

This commit is contained in:
Josh Smeaton 2017-01-14 13:33:27 +11:00
parent bcce6bb7c7
commit 8ade277ab1
1 changed files with 18 additions and 18 deletions

View File

@ -186,7 +186,7 @@ class AggregateTestCase(TestCase):
page_sum=Sum("pages")).defer('name').filter(pk=self.b1.pk) page_sum=Sum("pages")).defer('name').filter(pk=self.b1.pk)
rows = [ rows = [
(1, "159059725", 447, "The Definitive Guide to Django: Web Development Done Right") (self.b1.id, "159059725", 447, "The Definitive Guide to Django: Web Development Done Right")
] ]
self.assertQuerysetEqual( self.assertQuerysetEqual(
qs.order_by('pk'), rows, qs.order_by('pk'), rows,
@ -198,7 +198,7 @@ class AggregateTestCase(TestCase):
page_sum=Sum("pages")).defer('name').filter(pk=self.b1.pk) page_sum=Sum("pages")).defer('name').filter(pk=self.b1.pk)
rows = [ rows = [
(1, "159059725", 447, "Adrian Holovaty", (self.b1.id, "159059725", 447, "Adrian Holovaty",
"The Definitive Guide to Django: Web Development Done Right") "The Definitive Guide to Django: Web Development Done Right")
] ]
self.assertQuerysetEqual( self.assertQuerysetEqual(
@ -292,15 +292,15 @@ class AggregateTestCase(TestCase):
self.assertEqual( self.assertEqual(
books, [ books, [
{ {
"contact_id": 1, "contact_id": self.a1.id,
"id": 1, "id": self.b1.id,
"isbn": "159059725", "isbn": "159059725",
"mean_age": 34.5, "mean_age": 34.5,
"name": "The Definitive Guide to Django: Web Development Done Right", "name": "The Definitive Guide to Django: Web Development Done Right",
"pages": 447, "pages": 447,
"price": Approximate(Decimal("30")), "price": Approximate(Decimal("30")),
"pubdate": datetime.date(2007, 12, 6), "pubdate": datetime.date(2007, 12, 6),
"publisher_id": 1, "publisher_id": self.p1.id,
"rating": 4.5, "rating": 4.5,
} }
] ]
@ -315,7 +315,7 @@ class AggregateTestCase(TestCase):
self.assertEqual( self.assertEqual(
list(books), [ list(books), [
{ {
"pk": 1, "pk": self.b1.pk,
"isbn": "159059725", "isbn": "159059725",
"mean_age": 34.5, "mean_age": 34.5,
} }
@ -335,15 +335,15 @@ class AggregateTestCase(TestCase):
self.assertEqual( self.assertEqual(
list(books), [ list(books), [
{ {
"contact_id": 1, "contact_id": self.a1.id,
"id": 1, "id": self.b1.id,
"isbn": "159059725", "isbn": "159059725",
"mean_age": 34.5, "mean_age": 34.5,
"name": "The Definitive Guide to Django: Web Development Done Right", "name": "The Definitive Guide to Django: Web Development Done Right",
"pages": 447, "pages": 447,
"price": Approximate(Decimal("30")), "price": Approximate(Decimal("30")),
"pubdate": datetime.date(2007, 12, 6), "pubdate": datetime.date(2007, 12, 6),
"publisher_id": 1, "publisher_id": self.p1.id,
"rating": 4.5, "rating": 4.5,
} }
] ]
@ -517,7 +517,7 @@ class AggregateTestCase(TestCase):
""" """
Sum on a distinct() QuerySet should aggregate only the distinct items. Sum on a distinct() QuerySet should aggregate only the distinct items.
""" """
authors = Author.objects.filter(book__in=[5, 6]) authors = Author.objects.filter(book__in=[self.b5, self.b6])
self.assertEqual(authors.count(), 3) self.assertEqual(authors.count(), 3)
distinct_authors = authors.distinct() distinct_authors = authors.distinct()
@ -536,7 +536,7 @@ class AggregateTestCase(TestCase):
rating=3.5, rating=3.5,
price=Decimal("1000"), price=Decimal("1000"),
publisher=p, publisher=p,
contact_id=1, contact_id=self.a1.id,
pubdate=datetime.date(2008, 12, 1) pubdate=datetime.date(2008, 12, 1)
) )
Book.objects.create( Book.objects.create(
@ -546,7 +546,7 @@ class AggregateTestCase(TestCase):
rating=4.0, rating=4.0,
price=Decimal("1000"), price=Decimal("1000"),
publisher=p, publisher=p,
contact_id=1, contact_id=self.a1.id,
pubdate=datetime.date(2008, 12, 2) pubdate=datetime.date(2008, 12, 2)
) )
Book.objects.create( Book.objects.create(
@ -556,7 +556,7 @@ class AggregateTestCase(TestCase):
rating=4.5, rating=4.5,
price=Decimal("35"), price=Decimal("35"),
publisher=p, publisher=p,
contact_id=1, contact_id=self.a1.id,
pubdate=datetime.date(2008, 12, 3) pubdate=datetime.date(2008, 12, 3)
) )
@ -735,25 +735,25 @@ class AggregateTestCase(TestCase):
{ {
'earliest_book': datetime.date(1991, 10, 15), 'earliest_book': datetime.date(1991, 10, 15),
'num_awards': 9, 'num_awards': 9,
'id': 4, 'id': self.p4.id,
'name': 'Morgan Kaufmann' 'name': 'Morgan Kaufmann'
}, },
{ {
'earliest_book': datetime.date(1995, 1, 15), 'earliest_book': datetime.date(1995, 1, 15),
'num_awards': 7, 'num_awards': 7,
'id': 3, 'id': self.p3.id,
'name': 'Prentice Hall' 'name': 'Prentice Hall'
}, },
{ {
'earliest_book': datetime.date(2007, 12, 6), 'earliest_book': datetime.date(2007, 12, 6),
'num_awards': 3, 'num_awards': 3,
'id': 1, 'id': self.p1.id,
'name': 'Apress' 'name': 'Apress'
}, },
{ {
'earliest_book': datetime.date(2008, 3, 3), 'earliest_book': datetime.date(2008, 3, 3),
'num_awards': 1, 'num_awards': 1,
'id': 2, 'id': self.p2.id,
'name': 'Sams' 'name': 'Sams'
} }
] ]
@ -777,7 +777,7 @@ class AggregateTestCase(TestCase):
) )
self.assertEqual( self.assertEqual(
list(books), [ list(books), [
(1, "159059725", 34.5), (self.b1.id, "159059725", 34.5),
] ]
) )