Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Nov 19, 2024
1 parent 3e6411e commit 1989ab0
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions tests/raw_query_/test_raw_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ def assertSuccessfulRawQuery(
Execute the passed query against the passed model and check the output.
"""
results = list(model.objects.raw_aggregate(query))
self.assertProcessed(model, results, expected_results, expected_annotations)
self.assertAnnotations(results, expected_annotations)
expected_results = list(expected_results)
with self.assertNumQueries(0):
self.assertProcessed(model, results, expected_results, expected_annotations)
self.assertAnnotations(results, expected_annotations)

def assertProcessed(self, model, results, orig, expected_annotations=()):
"""Compare the results of a raw query against expected results."""
Expand Down Expand Up @@ -189,18 +191,6 @@ def test_many_to_many(self):
reviewers = Reviewer.objects.all()
self.assertSuccessfulRawQuery(Reviewer, query, reviewers)

def test_extra_projections(self):
"""Extra projections are ignored."""
query = [
{
"$project": {
"something": "else",
}
}
]
authors = Author.objects.all()
self.assertSuccessfulRawQuery(Author, query, authors)

def test_missing_fields(self):
query = [{"$project": {"id": 1, "first_name": 1, "dob": 1}}]
for author in Author.objects.raw_aggregate(query):
Expand All @@ -218,7 +208,7 @@ def test_annotations(self):
query = [
{
"$lookup": {
"from": "raw_query_book",
"from": "raw_query__book",
"localField": "_id",
"foreignField": "author_id",
"as": "books",
Expand Down

0 comments on commit 1989ab0

Please sign in to comment.