Skip to content
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

Getting tests passing #7

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

lastcraft
Copy link

No description provided.

colinhowe and others added 19 commits September 17, 2015 17:14
fix: noticket - dont dereference related on reload
In pymongo3, no need to use hosts_or_uri.
aa7cd5b broke the following test:

======================================================================
FAIL: test_ordering (tests.queryset.QuerySetTest)
    Ensure default ordering is applied and can be overridden.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
          File "/home/vagrant/conv_libs/mongoengine/tests/queryset.py",
          line 755, in test_ordering
              self.assertEqual(latest_post.title, "Blog Post #3")
          AssertionError: u'Blog Post #1' != 'Blog Post #3'

This is because we were no longer calling sort() on the cursor after
calling order_by.
6cc87c2 introduced a breaking change
causing the following test to fail:

FAIL: test_clone (tests.queryset.QuerySetTest)
    Ensure that cloning clones complex querysets
    ----------------------------------------------------------------------
    Traceback (most recent call last):
          File "/home/vagrant/conv_libs/mongoengine/tests/queryset.py",
          line 2496, in test_clone
              self.assertEqual(test.count(), test2.count())
          AssertionError: 89 != 10

However, it was not the .clone() call that was failing. The cursor that
had *not* been cloned was not having the limit() call applied because
the pymongo cursor had already been created.

The above commit introduced a similar error for skip() and hint() calls.
The test introduced to test skip() breaks without the change in place,
however, I could not find a test for hint() but I have re-introduced the
previous behaviour.
3d4b752 introduced a bug that caused
the following test to fail:

FAIL: test_pagination (tests.django_tests.QuerySetTest)
Ensure that Pagination works as expected
----------------------------------------------------------------------
Traceback (most recent call last):
  File
    "/home/vagrant/conv_libs/mongoengine/tests/django_tests.py",
    line 92, in test_pagination
      self.assertEqual(t.render(Context(d)), u'%d:%d:' % (start, end))
  AssertionError: u'3:4:5:6:' != u'3:4:'

Only in some very rare cases (that the Django Paginator exercised) was
paging/slicing broken. I couldn't get a reproducable test case that
showed the same behaviour outside of the Django Paginator :(
Fix Broken MongoEngine Tests (All commits reference the breaking change)
when comparing to different classes.

Why? Short reason: We have the concept of MongoRef (a light wrapper that
holds a pointer to a MongoEngine document). When performing basic
equality checks we would like a MongoRef and Document of the same
type/id to be considered equal.

This update causes MongoEngine to return NotImplemented instead of False
when comparing against things that are not the same class. Which will
allow us to implement/allow the comparison in our MongoRef class.

https://docs.python.org/2/reference/datamodel.html

NotImplemented

This type has a single value. There is a single object with this value.
This object is accessed through the built-in name NotImplemented.
Numeric methods and rich comparison methods may return this value if
they do not implement the operation for the operands provided. (The
interpreter will then try the reflected operation, or some other
fallback, depending on the operator.) Its truth value is true.
feat: noticket - Update Document __eq__/__ne__ to return NotImplemented
feat: noticket - add batch_size support to QuerySet
@lastcraft lastcraft force-pushed the getting_tests_passing branch from 6617050 to 0d4f501 Compare November 29, 2017 17:25
iainb pushed a commit to iainb/mongoengine that referenced this pull request Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants