-
-
Notifications
You must be signed in to change notification settings - Fork 3
adapt raw_query tests for QuerySet.raw_aggregate() #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will take a look at this shortly!
d03cf96
to
ff43b2b
Compare
tests/raw_query/tests.py
Outdated
query = [{"$match": {"last_name": "%(last)s" % {"last": "foo"}}}] | ||
qset = Author.objects.raw_mql(query) | ||
self.assertEqual( | ||
repr(qset), | ||
"<RawQuerySet: SELECT * FROM raw_query_author WHERE last_name = foo>", | ||
"<MongoRawQuerySet: [{'$match': {'last_name': 'foo'}}]>", | ||
) | ||
self.assertEqual( | ||
repr(qset.query), | ||
"<RawQuery: SELECT * FROM raw_query_author WHERE last_name = foo>", | ||
"<MongoRawQuery: [{'$match': {'last_name': 'foo'}}]>", | ||
) | ||
|
||
query = "SELECT * FROM raw_query_author WHERE last_name = %s" | ||
qset = Author.objects.raw(query, {"foo"}) | ||
query = [{"$match": {"last_name": "%s" % "foo"}}] | ||
qset = Author.objects.raw_mql(query) | ||
self.assertEqual( | ||
repr(qset), | ||
"<RawQuerySet: SELECT * FROM raw_query_author WHERE last_name = foo>", | ||
"<MongoRawQuerySet: [{'$match': {'last_name': 'foo'}}]>", | ||
) | ||
self.assertEqual( | ||
repr(qset.query), | ||
"<RawQuery: SELECT * FROM raw_query_author WHERE last_name = foo>", | ||
"<MongoRawQuery: [{'$match': {'last_name': 'foo'}}]>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these tests can be skipped since we ultimately don't support the params field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do need one test for __repr__()
but we don't need to test this redundantly or with a query that uses string interpolation. Let's continue to edit this file here (so we can see the diff against the raw_query
tests, but with the ultimate goal of putting this test app in the django-mongodb tests directory rather than merging these changes. So, for example, for tests that aren't applicable, remove them in the PR instead of adding skips.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. raw_query_
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a skip test to what I talked about before and then everything looks good to me!
The test condition can be "params not supported" or "translations not supported"
Looks like we're going to move to |
Co-authored-by: Tim Graham <[email protected]>
These tests are incorporated in django-mongodb's |
feature: mongodb/django-mongodb-backend#183
These tests are incorporated in django-mongodb's
tests/raw_query_/test_raw_aggregate.py
and this PR shows the diff of how they were adapted.