Commit Graph
285 Commits
Author SHA1 Message Date
Bastien GérardandGitHub 65f50fd713 Merge pull request #2387 from bagerard/fix_change_fields_inconsistencies
fix inconsistencies in ._changed_fields computation
2020-10-29 21:15:31 +01:00
Bastien Gérard d4350e7da4 Fix for ListField that isnt detecting properly that item 0 is changed 2020-10-10 23:32:22 +02:00
Bastien Gérard aabc18755c fix inconsistencies in ._changed_fields computation 2020-10-07 00:01:09 +02:00
Bastien Gérard aca4de728e Merge branch 'master' of github.com:MongoEngine/mongoengine into fix_count_documents_deprecation 2020-08-11 23:01:33 +02:00
Bastien Gérard ef7da36ac6 Update pre-commit and fix existing flake8 warnings once for all 2020-04-25 21:36:07 +02:00
Bastien Gérard 87f4d1a323 Merge branch 'master' of github.com:MongoEngine/mongoengine into drop_py2_support 2020-04-25 13:51:21 +02:00
Bastien Gérard ee2d50b2d1 remove drop_dups index option, deprecated with MongoDB3 2020-03-17 21:38:50 +01:00
Bastien Gérard 8086576677 get rid of six 2020-03-11 23:07:03 +01:00
Bastien Gérard e64a7a9448 reformat with latest black 2020-01-07 22:11:24 +01:00
Bastien Gérard 60c42dddd5 finalize code related to count_documents migration 2020-01-05 22:29:13 +01:00
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