Commit Graph

260 Commits

Author SHA1 Message Date
Julius Park
67a23429ba
PYTHON-1787: add details to OperationFailure exception and NotMasterError (#448)
PYTHON-1787-add details to OperationFailure and NotMasterError by adding a __repr__ function

https://jira.mongodb.org/browse/PYTHON-1787
2020-06-30 12:30:28 -04:00
Shane Harvey
0eace78cf4 PYTHON-2158 Support speculative authentication attempts in connection handshake 2020-05-19 11:20:23 -07:00
Shane Harvey
016f8de965 PYTHON-2155 Add MongoDB 4.4 to testing matrix 2020-03-17 15:12:02 -07:00
Shane Harvey
a460725f6b PYTHON-2019 Add support for validate command "background" option 2020-02-25 18:31:44 -08:00
Shane Harvey
9cf0fbd785
PYTHON-2001 Fix warnings emitted by Python 3.8 (#428)
Fix DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
Fix DeprecationWarning: isAlive() is deprecated, use is_alive() instead
Fix SyntaxWarning: invalid escape sequence
Test Python 3.8 on Travis
2019-11-08 11:48:15 -08:00
Shane Harvey
560415666a PYTHON-2023 Use $merge to non-admin db to fix db.aggregate write concern test 2019-10-25 15:56:47 -07:00
Shane Harvey
6de82d2526 PYTHON-1874 Fix coll.aggregate() when result is missing the "ns" field 2019-06-14 10:57:27 -07:00
Prashant Mital
81529713ba
PYTHON-1699 Add database level aggregate helper 2019-06-12 16:37:39 -07:00
Prashant Mital
749116287a
PYTHON-1783 Decode user-facing documents but not internal driver-server
communications.
2019-04-16 15:01:42 -07:00
Shane Harvey
11967eb160 PYTHON-1784 Add filter support to list_collection_names
Adhere to enumerate collection spec for setting nameOnly when filter
is provided to allow filtering based on collection options.
2019-03-22 17:06:51 -07:00
Shane Harvey
da2ba8d7ed PYTHON-1709 Always use codec_options in Database.current_op 2019-03-13 11:51:25 -07:00
Shane Harvey
c77a0d8e1f PYTHON-1719 Stop testing getpreverror on MongoDB 4.1+ 2019-01-31 17:00:26 -08:00
Shane Harvey
d43ca118f9 PYTHON-1654 Ignore $clusterTime in test_command assertion 2018-10-09 15:55:10 -07:00
Bernie Hackett
356eed66f5 PYTHON-1607 - Stop testing eval and SystemJS with MongoDB 4.1+ 2018-07-03 12:44:40 -07:00
Bernie Hackett
709b28467f PYTHON-1586 - Deprecate database_names and collection_names 2018-06-18 10:52:11 -07:00
Bernie Hackett
e6b0f3847d PYTHON-1581 - Deprecate Collection/Cursor count 2018-06-18 10:50:26 -07:00
Shane Harvey
9dd16cefc4 PYTHON-1549 Pop time fields before comparing last error responses 2018-05-03 09:57:46 -07:00
Bernie Hackett
5b9257644f PYTHON-1464 - Implement SCRAM-SHA-256 2018-03-06 17:54:40 -08:00
Bernie Hackett
4fa72033dd PYTHON-1488 - Fix auth tests for MongoDB 3.7 2018-02-26 15:32:55 -08:00
Bernie Hackett
cacc0ab877 PYTHON-1459 - Remove uses of the forceerror command 2018-02-13 09:59:23 -08:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
Bernie Hackett
f107c08754 PYTHON-1355 - list_collections improvements 2017-10-26 16:50:19 -07:00
jagrut
8468dfdd41 PYTHON-1355 Implement Collections Enumeration spec. (#336)
New method Collection.list_collections.
2017-10-24 14:15:01 -07:00
Shane Harvey
3e778334e7 PYTHON-1299 Remove test logic for MongoDB <2.6. 2017-09-29 12:09:24 -07:00
A. Jesse Jiryu Davis
72e61277b2 Deprecate db.authenticate and db.eval
PYTHON-1313, and PYTHON-1315.
2017-08-01 16:30:42 -04:00
Bernie Hackett
018afe4b80 PYTHON-1258 - Fix test_command for MongoDB 3.5+ 2017-03-25 13:08:00 -07:00
Bernie Hackett
e3b3d88928 PYTHON-1229 - Set max MongoDB version to 3.5.0 2017-02-17 13:55:50 -08:00
Bernie Hackett
b530755cfc PYTHON-1229 - Update another agg test for MongoDB 3.5+ 2017-02-17 13:55:50 -08:00
Bernie Hackett
9a6fdc1f8f PYTHON-1229 - Update aggregate tests for MongoDB 3.5+
The aggregate command now requires either the 'cursor' or 'explain'
option.
2017-02-17 13:55:50 -08:00
Shane Harvey
5905a86785 PYTHON-1075 Support running the entire test suite with SSL/TLS
SSL connections are configurable via the environment variables
"CLIENT_PEM", "CA_PEM", and "CERT_REQS".
2016-09-28 16:34:14 -07:00
Bernie Hackett
e89ba4bcd0 PYTHON-1026 - Remove test assumption about primary host 2016-09-21 11:15:43 -07:00
Luke Lovett
b36a4345fd PYTHON-1101 - Support sending writeConcern for commands that write. 2016-08-11 14:02:22 -07:00
Bernie Hackett
1ee5e27f9a Fix testing with no server 2016-06-24 10:28:18 -07:00
Bernie Hackett
53a7bea492 PYTHON-1022 - Drop support for Python 3.2
This change removes the u() helper from bson.py3compat
and all of its uses in the driver and tests. PyPy3 continues
to be supported since, even though it is based on python 3.2.5,
it has always supported the u string prefix.

The README and install docs are now explicit about PyPy(3) support.
2016-06-15 10:05:43 -07:00
Bernie Hackett
98dcaa2363 PYTHON-1056 - Disallow double quotes in database names 2016-03-02 16:25:50 -05:00
Luke Lovett
dde4a658b5 PYTHON-981 - Implement ReadConcern. 2015-11-18 14:12:28 -08:00
A. Jesse Jiryu Davis
06b32a00ab PYTHON-1003 Test _list_collections uses one socket at a time. 2015-10-16 17:06:06 -04:00
Bernie Hackett
f5eed9707c Fix up profiling tests for MongoDB 3.1.x 2015-09-11 16:28:36 -07:00
Luke Lovett
6a0d85451e Fix authentication error in test_authenticate_multiple for MongoDB 2.2 sharded. 2015-06-25 14:23:08 -07:00
Bernie Hackett
d3aa09a165 PYTHON-895 - Fix _list_collections OP_GET_MORE for legacy servers.
This also pedantically fixes the same issue for list_indexes, which
can't technically fail in the same way since you are limited
to 64 indexes on a collection.
2015-04-14 12:03:47 -07:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
Bernie Hackett
c87424e7af PYTHON-856 - as_class -> document_class
This commit changes the name of the as_class option
in CodecOptions to document_class, to match the name
of the MongoClient option.
2015-03-09 14:32:42 -07:00
Bernie Hackett
4fd6f8a0b1 PYTHON-854 max_pool_size -> maxPoolSize
With this change the max_pool_size named parameter to
MongoClient is removed. It is replaced by the maxPoolSize
MongoDB URI option, which can be passed in a URI, or as a
keyword argument to MongoClient.
2015-03-09 10:08:13 -07:00
Bernie Hackett
0b9d79fb92 Move another legacy test. 2015-03-06 08:32:18 -08:00
Bernie Hackett
21e1e1d67f PYTHON-850 - Fix an authentication test. 2015-02-26 16:40:45 -08:00
A. Jesse Jiryu Davis
7f42430978 PYTHON-847 Remove disconnect(), synonym of MongoClient.close().
close() seems more standard among MongoDB drivers.
2015-02-25 14:52:34 -05:00
Bernie Hackett
a817fa9a28 PYTHON-821 - Add test_legacy_api.py 2015-02-19 09:32:14 -08:00
Bernie Hackett
30af616009 PYTHON-821 - Migrate most tests to new the CRUD API. 2015-02-13 08:46:43 -08:00
A. Jesse Jiryu Davis
a2c13090d8 PYTHON-826 Move codec_options submodule from pymongo to bson. 2015-02-02 09:38:49 -05:00
A. Jesse Jiryu Davis
60b6dc6408 Clean up a stray user. 2015-01-26 16:38:16 -05:00
A. Jesse Jiryu Davis
301bf8066c Replace more tearDowns with addCleanup. 2015-01-26 16:38:16 -05:00
A. Jesse Jiryu Davis
0a75f04384 Remove pre-MongoDB-2.0 version checks from tests. 2015-01-26 16:19:12 -05:00
behackett
c07e543e58 PYTHON-820 - API changes for find/find_one to comply with CRUD spec.
- Changed parameter names (default values and behaviors remain the same):
  - spec (spec_or_id in find_one) -> filter
  - fields -> projection
  - partial -> allow_partial_results

- The "timeout" option is renamed to "no_cursor_timeout" with its default
  changed to False.

- The tailable, await_data, and exhaust options will be replaced with a
  cursor_type option. Valid values:
  - cursor.NON_TAILABLE
  - cursor.TAILABLE
  - cursor.TAILABLE_AWAIT
  - cursor.EXHAUST

- The following options are added:
  - oplog_replay (bool - default False) - only valid with tailable cursors
    against the oplog.
  - modifiers (document - default None) - A dict of query modifiers. See
    http://docs.mongodb.org/manual/reference/operator/query-modifier/#modifiers for
    options.

- The following options are removed, replaced by the "modifiers" option:
  - max_scan
  - snapshot

- The as_class option is removed. Use Collection.with_options instead.
2015-01-19 22:10:56 -08:00
Bernie Hackett
755d5c74eb PYTHON-814 - API and behavior changes for Database.command.
Database.command no longer obeys Database.read_preference or
Database.codec_options. Explicit parameters have been added
for both options. See the ticket for a full explanation.
2015-01-09 13:18:36 -08:00
A. Jesse Jiryu Davis
89466cd3f9 Clean up test_auto_ref_and_deref_list. 2014-12-22 14:49:11 -06:00
Bernie Hackett
1b1457ab1f PYTHON-677 - Finish transition to WriteConcern. 2014-12-20 22:34:48 -08:00
A. Jesse Jiryu Davis
5fed41b0fb PYTHON-807 Silence warnings when testing Database.error(). 2014-12-20 09:31:28 -05:00
Bernie Hackett
550f25370e PYTHON-802 - Add get_database and get_collection methods 2014-12-15 11:01:29 -08:00
A. Jesse Jiryu Davis
108e97baad Unused imports in tests. 2014-12-10 14:11:33 -05:00
A. Jesse Jiryu Davis
2ba730722b PYTHON-526 Remove 'compile_re' option.
PyMongo now never attempts to compile BSON regular expressions as Python native
regular expressions.
2014-12-05 14:06:38 -05:00
A. Jesse Jiryu Davis
620c1bd491 Fix test_default_roles to work with mongo-orchestration. 2014-11-24 14:20:47 -05:00
A. Jesse Jiryu Davis
e8be121a89 PYTHON-785 Don't use requests in tests. 2014-11-20 22:57:56 -05:00
A. Jesse Jiryu Davis
13cb74a760 Simplify auth tests, don't create additional root users.
Don't log out the global test client either; keep it logged in as root and
use it to create additional non-root users to test Database.add_user,
authenticate, logout, and so on.
2014-11-17 21:39:22 -05:00
A. Jesse Jiryu Davis
4948c04d6a Fix add_user tests for MongoDB 2.4. 2014-11-14 22:18:59 -05:00
Bernie Hackett
6ff8b3669b PYTHON-781 - Fix tests for multiple storage engines.
Remove a few seemingly pointless test cases that
aren't portable across server versions, storage engines,
etc.
2014-10-31 13:30:02 -07:00
A. Jesse Jiryu Davis
72513df373 PYTHON-766 Demonstrate a bug parsing an error message from mongos. 2014-10-07 19:45:16 -04:00
A. Jesse Jiryu Davis
c5eae2f99f Use replica set connection in tests wherever possible.
Most tests now inherit from IntegrationTest and use self.client for all MongoDB
operations. self.client is now a replica set connection if an RS is available,
otherwise a connection to a standalone.
2014-10-07 13:36:52 -04:00
A. Jesse Jiryu Davis
366e11d529 Silence DeprecationWarnings in add_user tests. 2014-10-06 22:32:01 -04:00
A. Jesse Jiryu Davis
de215fe88b Fix MongoClient.__getattr__ implementation.
Before, MongoClient._does_not_exist had raised AttributeError, 'super' object has no
attribute '__getattr__'. Now it raises, AttributeError: MongoClient has no attribute
'_does_not_exist'. To access the _does_not_exist database, use client['_does_not_exist'].
2014-10-02 17:41:49 -04:00
Bernie Hackett
43fd070ad3 PYTHON-493 - Add **kwargs to Database.dereference 2014-09-26 16:23:03 -07:00
Bernie Hackett
fd880545bf PYTHON-700 - Support subclassing of son manipulators 2014-09-24 09:40:33 -07:00
Bernie Hackett
8f64e476ba PYTHON-480 - Filter __getattr__ lookups.
After this change creating instances of Database or
Collection with a name starting with a leading underscore
requires dict-style access on the parent object. This
solves problems with ipython code completion and ABCMeta
while still preserving the ability to access databases and
collections named this way.
2014-09-23 15:41:41 -07:00
Bernie Hackett
9c8852d93f PYTHON-760 - BSONInt64 -> Int64 2014-09-23 11:43:41 -07:00
A. Jesse Jiryu Davis
735a1247ca PYTHON-525 Deprecate MongoReplicaSetClient.
MongoClient now supports all MongoReplicaSetClient's features.
Fix bugs and add features in the new MongoClient to bring it up
to spec. MongoReplicaSetClient is now a deprecated stub that
subclasses MongoClient.

Introduce new errors, NetworkTimeout and NotMasterError, to
communicate events that MongoClient must handle specially.
2014-09-16 15:33:19 -04:00
A. Jesse Jiryu Davis
41c1a9afa6 PYTHON-525 Reimplement auth for new MongoClient.
The new MongoClient, based on Cluster and Server,
includes functionality that had been split between the
old MongoClient and MongoReplicaSetClient. A
previous commit introduced the new MongoClient
but broke authentication.
2014-09-03 17:39:52 -04:00
A. Jesse Jiryu Davis
2f9d24ade6 PYTHON-525 Reimplement MongoClient to use Cluster.
Replace MongoClient with an implementation that relies on Cluster and Server. The new MongoClient takes over MongoReplicaSetClient's responsibilities.

Authentication, secondary-pinning, and Mongos high-availability are broken and will be reimplemented in a future commit. RS tests are temporarily disabled.
2014-08-28 16:57:57 -04:00
Luke Lovett
5136bb723c PYTHON-707 Add a BSONInt64 type. 2014-07-18 14:59:21 +00:00
A. Jesse Jiryu Davis
118b47e6e3 Unused imports. 2014-07-17 15:23:40 -04:00
Luke Lovett
d7ec3a7704 PYTHON-715 Fix tests for MongoDB >= 2.7.1 when running with auth enabled. 2014-07-07 19:05:21 +00:00
Luke Lovett
4fa96c6c2e PYTHON-683 Separate unit tests and integration tests in the pymongo test suite.
Raise SkipTest in tests that require a connection to MongoDB when none is available.
2014-06-30 17:42:29 +00:00
A. Jesse Jiryu Davis
ac512ce170 PYTHON-709 insert _id in document after applying non-copying SONManipulators. 2014-06-19 14:51:09 -04:00
Luke Lovett
e8d44cf6c4 PYTHON-681 Make sure forceerror command and subsequent calls to error() and previous_error() happen on same socket in tests 2014-05-21 22:39:11 +00:00
Luke Lovett
26fb43cf78 PYTHON-681 Reuse MongoClient whenever possible in the tests 2014-05-21 20:41:18 +00:00
Bernie Hackett
69b430ac73 Fix a few tests for MongoDB 2.7.0 2014-05-12 14:16:59 -07:00
Bernie Hackett
becc359cad Various fixes for auth tests with old mongos versions. 2014-05-02 15:24:32 -07:00
Bernie Hackett
b8ba0bddae Fix a few tests with really old mongos versions. 2014-05-01 19:33:21 -07:00
behackett
86c0df0341 Use catch_warnings to test warnings. 2014-04-28 11:49:50 -07:00
Luke Lovett
141200083e PYTHON-680 Stop using nose in favor of pure unittest/unittest2 2014-04-25 22:57:33 +00:00
Luke Lovett
4d6d1e067b PYTHON-676 python 2/3 single-source for the test module 2014-04-23 18:37:02 +00:00
Bernie Hackett
814434c1b2 PYTHON-526 Remove the network_timeout query option.
This was always a misguided feature. Using a socket timeout
to "timeout" MongoDB queries is awful for a few reasons:

- It leaves the query running on the server, wasting resources.
- It causes a socket to be closed and discarded unnecessarily.
- Applications that use this tend to immediately retry the query,
often causing another timeout and more wasted resources.

There are three remaining ways to use timeouts with PyMongo:

- connectTimeoutMS - Global setting for timing out a socket's
initial connection to the server.
- socketTimeoutMS - Global setting for timing out any socket
operation. *Do not* use this to enforce time limits on server
side operations.
- max_time_ms (or maxTimeoutMS as a command kwarg) - MongoDB 2.6
server side timebomb for queries and commands. This is a server
side option, passed along with a query or command, that causes
MongoDB to abort the operation if it takes longer than the specified
limit.
2014-04-05 09:59:38 -07:00
Bernie Hackett
22caa27a72 Add more tests for maxTimeMS PYTHON-550 2014-03-04 10:35:45 -08:00
Bernie Hackett
502b7d4c0c Fix tox compatibility.
The tox testing tool has dropped support for python 2.5
(and therefore jython) and by default sets PYTHONHASHSEED
to a random value. pip is dropping python 3.1 in its next
release so we might as well drop that from tox.ini now as
well.
2014-02-25 12:35:37 -08:00
A. Jesse Jiryu Davis
1361579c82 add_user(name, read_only=True) should update existing user in MongoDB 2.6, PYTHON-643. 2014-02-24 13:53:13 -05:00
A. Jesse Jiryu Davis
2fa1750b07 Update copyright notices and company name. 2014-01-31 09:36:46 -05:00
Bernie Hackett
1a8071cc6b Use w=0 in gle test - work around SERVER-12474
GLE behavior is undefined after a write command
so use the legacy wire protocol messages in this
test.
2014-01-30 08:43:42 -08:00
A. Jesse Jiryu Davis
8f6a34326e Improve multithreaded connection and reconnection in MongoClient, PYTHON-487. 2013-12-04 21:09:15 -05:00
Bernie Hackett
3ddb001129 Fix profiler test for mongo 2.5.x nightly 2013-11-15 16:25:11 -08:00
Bernie Hackett
0cb632784a Skip auth tests if auth not enabled PYTHON-556
This change does a few things:

1. In anticipation of the server defaulting to a "disabled" mode for
auth, only run authentication related tests if auth is enabled.
2. Attempt to clean up users in a finally block, even if tests failed.
3. Look for auth settings in "parsed" from getCmdLineOpts in case the
cluster was started with config files.
4. Remove useless remove_all_users calls at the beginning of tests - if
users were added in a previous test and we forgot to clean them up
these are going to fail no matter what when auth is enabled.
2013-11-05 09:10:00 -08:00
Amalia Hawkins
1ee488cc6d PYTHON-577: Warn when a command is redirected to the primary and read preference is not primary 2013-10-31 15:08:37 -07:00
Bernie Hackett
add8d4fd6a More warnings cleanup. 2013-10-31 12:04:21 -07:00