Commit Graph
275 Commits
Author SHA1 Message Date
Bastien Gérard c85b59d3b5 Merge branch 'master' of github.com:MongoEngine/mongoengine into negative_indexes_in_list 2019-12-20 23:27:51 +01:00
Bastien Gérard 332bd767d4 minor fixes in tests 2019-12-20 23:20:15 +01:00
Eric Timmons 68dc2925fb Add LazyReferenceField with dbref=True to embedded_document equality test 2019-12-15 20:21:22 -05:00
Eric Timmons dc7b96a569 Make python value for LazyReferenceFields be a DBRef
Previously, when reading a LazyReferenceField from the DB, it was stored
internally in the parent document's _data field as an ObjectId. However, this
meant that equality tests using an enclosing EmbeddedDocument would not return
True when the EmbeddedDocument being compared to contained a DBRef or Document
in _data. Enclosing Documents were largely unaffected because they look at the
primary key for equality (which EmbeddedDocuments lack).

This makes the internal Python representation of a LazyReferenceField (before
the LazyReference itself has been constructed) a DBRef, using code identical to
ReferenceField.
2019-12-15 20:20:59 -05:00
Eric Timmons 50882e5bb0 Add failing test
Test that __eq__ for EmbeddedDocuments with LazyReferenceFields works as
expected.
2019-12-15 20:20:59 -05:00
Bastien Gérard 78b240b740 updated changelog + improved query_counter test 2019-12-04 21:51:07 +01:00
Eloi Zalczer 0bf08db7b9 Added test case for query_counter alias 2019-12-02 10:07:33 +01:00
Bastien GérardandGitHub 138e759161 Merge pull request #2187 from bagerard/improve_error_message_InvalidDocumentError
Improve error message from InvalidDocumentError
2019-11-08 21:27:17 +01:00
Bastien Gérard 81647d67a0 fix recent tests update with unittest2pytest 2019-10-31 23:06:40 +01:00
Bastien Gérard 799cdafae6 remove references to nose 2019-10-31 23:02:28 +01:00
Bastien Gérard bc0c55e49a improve tests health (flake8 warnings) 2019-10-31 23:01:27 +01:00
Bastien Gérard c61c6a8525 fix == None assertions 2019-10-31 22:59:49 +01:00
Bastien Gérard 3e764d068c fix remaining assertRaises 2019-10-31 22:59:49 +01:00
Bastien Gérard ac25f4b98b ran unittest2pytest 2019-10-31 22:59:49 +01:00
Bastien Gérard 37ca79e9c5 fix black formatting 2019-10-31 22:39:53 +01:00
Bastien Gérard 54ca7bf09f fix associated test to avoid discrepencies btw py2 and py3 2019-10-28 23:33:37 +01:00
Bastien Gérard 8bf5370b6c Improve error message from InvalidDocumentError whenever an embedded document has a bad shape (e.g due to migration) 2019-10-28 22:05:13 +01:00
otrofimov 47c67ecc99 Merge branch 'master' of https://github.com/MongoEngine/mongoengine 2019-08-29 11:48:07 +03:00
Bastien Gérard ddececbfea rename all test files so that they are prefixed by test_{orginal_filename}.py 2019-08-28 16:01:44 +03:00
otrofimov 71a6f3d1a4 test_collation:
Added test with `pymongo.collation.Collation` object
Readable list of BlogPost names for test
2019-08-21 18:26:10 +03:00
otrofimov fbb3bf869c compatibility with black 2019-08-08 15:56:20 +03:00
otrofimov b887ea9623 Implement collation for queryset 2019-08-08 11:55:45 +03:00
Bastien Gérard c68e3e1238 Add test case for list update by negative index 2019-07-24 21:37:16 +02:00
Stefan WójcikandGitHub ac416aeeb3 Improve BaseDocument.from_json tests and documentation (#2127) 2019-07-15 12:15:55 +02:00
Stefan WójcikandGitHub aa76ccdd25 Fix Document._object_key (#2125)
Previous implementation of `Document._object_key` was *pretending* to work on
MongoEngine-level fields (e.g. using "pk" instead of "_id" and separating
nested field parts by "__" instead of "."), but then it was also attempting to
transform field names from the `shard_key` into DB-level fields.

This, expectedly, didn't really work well. Most of the test cases added in this
commit were failing prior to the code fixes.
2019-07-09 12:08:26 +02:00
Stefan WójcikandGitHub b47669403b Format the codebase using Black (#2109)
This commit:
1. Formats all of our existing code using `black`.
2. Adds a note about using `black` to `CONTRIBUTING.rst`.
3. Runs `black --check` as part of CI (failing builds that aren't properly formatted).
2019-06-27 13:05:54 +02:00
Stefan Wojcik e57d834a0d Fix automated tests for py3 2019-06-25 12:41:59 +02:00
Stefan Wojcik f45552f8f8 Drop support for positional arguments when instantiating a document
For example, if you had the following class:
```
class Person(Document):
    name = StringField()
    age = IntField()
```

You could instantiate an object of such class by doing one of the following:
1. `new_person = Person('Tom', 30)`
2. `new_person = Person('Tom', age=30)`
3. `new_person = Person(name='Tom', age=30)`

From now on, only option (3) is allowed.

Supporting positional arguments may sound like a reasonable idea in this
heavily simplified example, but in real life it's almost never what you want
(especially if you use inheritance in your document definitions) and it may
lead to ugly bugs. We should not rely on the *order* of fields to match a given
value to a given name.

This also helps us simplify the code e.g. by dropping the confusing (and
undocumented) `BaseDocument._auto_id_field` attribute.
2019-06-24 15:44:35 +02:00
Bastien Gérard 2abcf4764d minor fixes based on review of #2082 2019-06-18 22:15:53 +02:00
Stefan WójcikandGitHub bb0b1e88ef Split up custom PK field tests (#2095)
This more closely aligns with the rule that a single tests should test one
thing and one thing only. Previous code tested like 4 different things in a
single test and was hard to follow.
2019-06-18 15:43:46 +02:00
Bastien Gérard 5a2e268160 Add test case to prevent regression 2019-06-17 22:19:41 +02:00
erdenezulandGitHub 1f02d5fbbd Merge pull request #1570 from erdenezul/remove_save_embedded
EmbeddedDocument should not have save method #1552
2019-06-11 16:15:53 +02:00
Stefan Wojcik f131b18cbe Make test_update_shard_key_routing more resilient 2019-06-11 15:50:22 +02:00
Erdenezul Batmunkh 7ad6f036e7 Remove test 2019-06-11 13:16:33 +02:00
Erdenezul Batmunkh 1d29b824a8 Remove save method from test 2019-06-11 12:52:29 +02:00
Stefan Wojcik 8e8c74c621 Drop the unused mongodb_version attribute in IndexesTest 2019-06-07 12:35:38 +02:00
Stefan Wojcik f996f3df74 Cleaner test_hint 2019-06-07 12:34:32 +02:00
Bastien Gérard 15f4d4fee6 fix tests for diff mongo vers 2019-06-05 21:51:21 +02:00
Bastien Gérard b407c0e6c6 add test for shard key routing (ported from https://github.com/closeio/mongoengine/commit/43f35f5) 2019-06-04 23:17:10 +02:00
Bastien Gérard 962997ed16 fix flaky test due to signal receiver garbage collection 2019-06-01 11:13:28 +02:00
Bastien Gérard 9ae8fe7c2d Improve perf of Doc.save by preventing a full to_mongo() call just to get the created variable 2019-06-01 11:13:28 +02:00
Stefan WójcikandGitHub 4334955e39 Update the test matrix to reflect what's supported in 2019 (#2066)
Previously, we were running the test suite for several combinations of MongoDB,
Python, and PyMongo:
- PyPy, MongoDB v2.6, PyMongo v3.x (which really means v3.6.1 at the moment)
- Python v2.7, MongoDB v2.6, PyMongo v3.x
- Python v3.5, MongoDB v2.6, PyMongo v3.x
- Python v3.6, MongoDB v2.6, PyMongo v3.x
- Python v2.7, MongoDB v3.0, PyMongo v3.5.0
- Python v3.6, MongoDB v3.0, PyMongo v3.5.0
- Python v3.5, MongoDB v3.2, PyMongo v3.x
- Python v3.6, MongoDB v3.2, PyMongo v3.x
- Python v3.6, MongoDB v3.4, PyMongo v3.x
- Python v3.6, MongoDB v3.6, PyMongo v3.x

There were a couple issues with this setup:
1. MongoDB v2.6 – v3.2 have reached their End of Life already (v2.6 almost 3
   years ago!). See the "MongoDB Server" section on
   https://www.mongodb.com/support-policy.
2. We were only testing two recent-ish PyMongo versions (v3.5.0 & v3.6.1).
   We were not testing the oldest actively supported MongoDB/PyMongo/Python
   setup.

This PR updates the test matrix so that these problems are solved. For the
sake of simplicity, it does not yet attempt to cover MongoDB v4.0:
- PyPy, MongoDB v3.4, PyMongo v3.x (aka v3.6.1 at the moment)
- Python v2.7, MongoDB v3.4, PyMongo v3.x
- Python v3.5, MongoDB v3.4, PyMongo v3.x
- Python v3.6, MongoDB v3.4, PyMongo v3.x
- Python v2.7, MongoDB v3.4, PyMongo v3.4
- Python v3.6, MongoDB v3.6, PyMongo v3.x
2019-05-31 11:01:15 +02:00
Bastien Gérard 6e1c132ee8 Improve minor things in the tests 2019-05-26 22:17:58 +02:00
Bastien Gérard c82f0c937d more work on coverage 2019-05-17 22:04:28 +02:00
Bastien Gérard 00d2fd685a more test cov 2019-05-17 22:04:28 +02:00
erdenezulandGitHub b70ffc69df Merge branch 'master' into bump_pymongo_version_requirement 2019-03-19 08:50:21 +08:00
Paulo Amaral ba6a37f315 Generate Unique Indices for SortedListField and EmbeddedDocumentListFields 2019-03-18 11:32:53 +00:00
Bastien Gérard 68497542b3 Bump the required version of pymongo to >=3.5 2019-03-17 22:04:19 +01:00
Bastien Gérard b4fe0b35e4 Merge branch 'master' of github.com:MongoEngine/mongoengine into refactor_deprecated_pymongo_test 2019-03-02 21:48:41 +01:00
Bastien Gérard 35b7efe3f4 refactored deprecated pymongo methods in tests
- remove/count/add_user/insert
- added pymongo_support
2019-03-02 00:28:38 +01:00