67 Commits

Author SHA1 Message Date
Bastien Gerard
b9d370c885 add standard hooks 2021-03-29 22:02:57 +02:00
Bastien Gerard
ff596fcb7e replace flake8-import-order by isort 2021-03-29 21:50:22 +02:00
Bastien Gerard
65b8cfc96a Improve mongomock tests to avoid regression 2020-12-14 00:03:39 +01:00
Bastien Gerard
c00a378776 autoformat with updated black 2020-12-13 00:14:52 +01: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
928770c43a switching to count_documents 2020-01-05 21:01:03 +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
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
5bcc679194 fix 2 pymongo deprecation warnings 2019-10-10 22:55:44 +02:00
Nuno Rodrigues
05a22d5a54 Extract test to its own method 2019-07-22 08:42:17 +00:00
Nuno Rodrigues
2424ece0c5 Fix a linting error 2019-07-16 13:40:46 +00:00
Nuno Rodrigues
2d02551d0a Add test 2019-07-15 17:54:46 +01:00
Stefan Wójcik
9170eea784
Rename MongoEngineConnectionError to ConnectionFailure (#2111)
I originally changed the exception name from `ConnectionError` to
`MongoEngineConnectionError` in
b02904ee75,
inspired by landscape.io's package health report, which argued that
`ConnectionError` is already a built-in exception in Python 3 (which it is:
https://docs.python.org/3/library/exceptions.html#ConnectionError).

I do agree that we shouldn't override built-in exceptions. [0] That said, it’s
silly to add a "MongoEngine" prefix to any class within the `mongoengine`
module (and *especially* to *just one* exception class out of many). I've
decided to do what PyMongo does (
8855a510a8/pymongo/errors.py (L59))
and call this exception `ConnectionFailure`.

Note that this is a breaking change and people will need to rename
`MongoEngineConnectionError`s in their code to `ConnectionFailure`. Moreover,
if they use PyMongo's `ConnectionFailure` for anything, they'll need to take
    extra care to avoid conflicts, e.g. by using:
```
from mongoengine import ConnectionFailure as MongoEngineConnectionFailure
```

[0] Note that some popular packages still overwrite `ConnectionError`, e.g.
4983a9bde3/requests/exceptions.py (L32)
or
0be4d29206/redis/exceptions.py (L8)
2019-06-30 09:23:32 +02:00
Stefan Wójcik
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
Bastien Gérard
84c42ed58c Add tests 2019-06-04 22:35:42 +02:00
Bastien Gérard
cf38ef70cb Remove more code related to supporting pymongo2 2019-05-15 22:23:35 +02:00
Bastien Gérard
ac64ade10f remove dead code (related to pymongo2) + minor cleaning 2019-05-15 21:54:47 +02:00
Bastien Gérard
cb578c84e2 Merge branch 'master' of github.com:MongoEngine/mongoengine into disconnect 2019-04-25 22:15:48 +02:00
Bastien Gérard
565e1dc0ed minor improvements 2019-04-25 22:11:43 +02:00
Bastien Gérard
b1e28d02f7 Improve connect/disconnect
- document disconnect + sample of usage
- add more test cases to prevent github issues regressions
2019-04-24 22:44:07 +02:00
Bastien Gérard
d1467c2f73 Fix connect/disconnect functions
- expose disconnect
- disconnect cleans _connection_settings
- disconnect cleans cached collection in Document._collection
- re-connecting with the same alias raise an error (must call disconnect in between)
2019-04-24 22:41:56 +02:00
Yurii Andrieiev
b5213097e8 Fail fast when db name is invalid
Without this commit save operation on first document would fail instead of immediate failure upon connection attempt. Such later failure is much less obvious.
2019-04-07 23:21:12 +03: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
35b7efe3f4 refactored deprecated pymongo methods in tests
- remove/count/add_user/insert
- added pymongo_support
2019-03-02 00:28:38 +01:00
Bastien Gérard
c60c2ee8d0 fix minor styling issue in tests 2019-02-25 22:33:36 +01:00
Bastien Gérard
003827e916 rewrote some poorly written assertions like: assertTrue(isinstance(a, b)) assertTrue(a==b) assertTrue(a!=b) assertTrue(a in b) 2018-09-06 21:47:06 +02:00
Erdenezul Batmunkh
5c4ce8754e run tests only pymongo3 #1565 2017-10-02 23:15:37 +08:00
Erdenezul Batmunkh
2f075be6f8 parse read_preference from conn_host #1665 2017-10-02 22:46:27 +08:00
Stefan Wójcik
5f43c032f2 revamp the "connecting" user guide and test more ways of connecting to a replica set (#1490) 2017-02-26 21:29:06 -05:00
Omer Katz
2bedb36d7f Test against multiple MongoDB versions in Travis (#1074) 2017-02-26 14:52:43 -05:00
Stefan Wójcik
e93a95d0cb Test and document controlling the size of the connection pool (#1489) 2017-02-25 14:09:10 -05:00
Stefan Wójcik
c6240ca415 Test connection's write concern (#1456) 2016-12-29 12:37:38 -05:00
Stefan Wojcik
553f496d84 fix tests 2016-12-13 00:42:03 -05:00
Stefan Wojcik
65914fb2b2 fix the way MongoDB URI w/ ?replicaset is passed 2016-12-12 23:24:19 -05:00
Stefan Wójcik
835d3c3d18 Improve the health of this package (#1428) 2016-12-11 18:49:21 -05:00
Stefan Wójcik
f168682a68 Dont let the MongoDB URI override connection settings it doesnt explicitly specify (#1421) 2016-12-05 22:31:00 -05:00
Jeff Tharp
f7ac8cea90 Fix connecting to a list of hosts 2016-10-19 11:57:02 -07:00
Emmanuel Leblond
13897db6d3 Fix mongomock url prefix error during connection 2016-01-20 11:06:45 +01:00
RussellLuo
23f07fde5e Add support for mocking MongoEngine based on mongomock
Using `mongomock://` scheme in URI enables the mocking. Fix #1045.
2015-12-06 11:08:00 +08:00
Emmanuel Leblond
96cfbb201a Replace use close method in pymongo 2015-08-04 18:02:57 +02:00
Matthieu Rigal
5c807f3dc8 Various test adjustments to improve stability independantly of execution order 2015-06-22 16:41:36 +02:00
Matthieu Rigal
c41dd6495d corrected connection test for PyMongo3+ 2015-05-07 12:47:31 +02:00
Matthieu Rigal
f4478fc762 removed sleep thanks to @seglberg suggestion 2015-05-07 12:47:31 +02:00
mrigal
48316ba60d implemented global IS_PYMONGO_3 2015-05-07 12:47:29 +02:00
mrigal
a34fa74eaa fix connection problems with pymongo3 and added tests 2015-05-07 12:47:29 +02:00