diff options
| author | Josh Smeaton <josh.smeaton@gmail.com> | 2015-02-23 11:53:57 +1100 |
|---|---|---|
| committer | Josh Smeaton <josh.smeaton@gmail.com> | 2015-03-05 10:10:32 +1100 |
| commit | 39a7eed1bbf12020a077e4bec3d82e08f171a021 (patch) | |
| tree | 225be14a94d57517d9de646569498eb45d0a4352 /tests/raw_query | |
| parent | d6969abf239d52f6dfed7384c6ceb7df7e618342 (diff) | |
Converted test fixtures to setUpTestData methods
Diffstat (limited to 'tests/raw_query')
| -rw-r--r-- | tests/raw_query/fixtures/raw_query_books.json | 110 | ||||
| -rw-r--r-- | tests/raw_query/tests.py | 17 |
2 files changed, 16 insertions, 111 deletions
diff --git a/tests/raw_query/fixtures/raw_query_books.json b/tests/raw_query/fixtures/raw_query_books.json deleted file mode 100644 index 35879aa5eb..0000000000 --- a/tests/raw_query/fixtures/raw_query_books.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "pk": 1, - "model": "raw_query.author", - "fields": { - "dob": "1950-09-20", - "first_name": "Joe", - "last_name": "Smith" - } - }, - { - "pk": 2, - "model": "raw_query.author", - "fields": { - "dob": "1920-04-02", - "first_name": "Jill", - "last_name": "Doe" - } - }, - { - "pk": 3, - "model": "raw_query.author", - "fields": { - "dob": "1986-01-25", - "first_name": "Bob", - "last_name": "Smith" - } - }, - { - "pk": 4, - "model": "raw_query.author", - "fields": { - "dob": "1932-05-10", - "first_name": "Bill", - "last_name": "Jones" - } - }, - { - "pk": 1, - "model": "raw_query.book", - "fields": { - "author": 1, - "title": "The awesome book", - "paperback": false, - "opening_line": "It was a bright cold day in April and the clocks were striking thirteen." - } - }, - { - "pk": 2, - "model": "raw_query.book", - "fields": { - "author": 1, - "title": "The horrible book", - "paperback": true, - "opening_line": "On an evening in the latter part of May a middle-aged man was walking homeward from Shaston to the village of Marlott, in the adjoining Vale of Blakemore, or Blackmoor." - } - }, - { - "pk": 3, - "model": "raw_query.book", - "fields": { - "author": 1, - "title": "Another awesome book", - "paperback": false, - "opening_line": "A squat grey building of only thirty-four stories." - } - }, - { - "pk": 4, - "model": "raw_query.book", - "fields": { - "author": 3, - "title": "Some other book", - "paperback": true, - "opening_line": "It was the day my grandmother exploded." - } - }, - { - "pk": 1, - "model": "raw_query.coffee", - "fields": { - "brand": "dunkin doughnuts" - } - }, - { - "pk": 2, - "model": "raw_query.coffee", - "fields": { - "brand": "starbucks" - } - }, - { - "pk": 1, - "model": "raw_query.reviewer", - "fields": { - "reviewed": [ - 2, - 3, - 4 - ] - } - }, - { - "pk": 2, - "model": "raw_query.reviewer", - "fields": { - "reviewed": [] - } - } -] diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py index 5d2bf4becf..2027a32d2b 100644 --- a/tests/raw_query/tests.py +++ b/tests/raw_query/tests.py @@ -9,7 +9,22 @@ from .models import Author, Book, Coffee, FriendlyAuthor, Reviewer class RawQueryTests(TestCase): - fixtures = ['raw_query_books.json'] + + @classmethod + def setUpTestData(cls): + cls.a1 = Author.objects.create(first_name='Joe', last_name='Smith', dob=date(1950, 9, 20)) + cls.a2 = Author.objects.create(first_name='Jill', last_name='Doe', dob=date(1920, 4, 2)) + cls.a3 = Author.objects.create(first_name='Bob', last_name='Smith', dob=date(1986, 1, 25)) + cls.a4 = Author.objects.create(first_name='Bill', last_name='Jones', dob=date(1932, 5, 10)) + cls.b1 = Book.objects.create(title='The awesome book', author=cls.a1, paperback=False, opening_line='It was a bright cold day in April and the clocks were striking thirteen.') + cls.b2 = Book.objects.create(title='The horrible book', author=cls.a1, paperback=True, opening_line='On an evening in the latter part of May a middle-aged man was walking homeward from Shaston to the village of Marlott, in the adjoining Vale of Blakemore, or Blackmoor.') + cls.b3 = Book.objects.create(title='Another awesome book', author=cls.a1, paperback=False, opening_line='A squat grey building of only thirty-four stories.') + cls.b4 = Book.objects.create(title='Some other book', author=cls.a3, paperback=True, opening_line='It was the day my grandmother exploded.') + cls.c1 = Coffee.objects.create(brand='dunkin doughnuts') + cls.c2 = Coffee.objects.create(brand='starbucks') + cls.r1 = Reviewer.objects.create() + cls.r2 = Reviewer.objects.create() + cls.r1.reviewed.add(cls.b2, cls.b3, cls.b4) def assertSuccessfulRawQuery(self, model, query, expected_results, expected_annotations=(), params=[], translations=None): |
