PYTHON-4931 Add spec tests for GridFS rename (#2431)
This commit is contained in:
parent
4a29fbda69
commit
83fcf7cd08
@ -8,7 +8,6 @@ rm $PYMONGO/test/client-side-encryption/spec/unified/fle2v2-EncryptedFields-vs-E
|
||||
rm $PYMONGO/test/client-side-encryption/spec/unified/localSchema.json # PYTHON-5143
|
||||
rm $PYMONGO/test/client-side-encryption/spec/unified/maxWireVersion.json # PYTHON-5143
|
||||
rm $PYMONGO/test/unified-test-format/valid-pass/poc-queryable-encryption.json # PYTHON-5143
|
||||
rm $PYMONGO/test/gridfs/rename.json # PYTHON-4931
|
||||
rm $PYMONGO/test/discovery_and_monitoring/unified/pool-clear-application-error.json # PYTHON-4918
|
||||
rm $PYMONGO/test/discovery_and_monitoring/unified/pool-clear-checkout-error.json # PYTHON-4918
|
||||
rm $PYMONGO/test/discovery_and_monitoring/unified/pool-clear-min-pool-size-error.json # PYTHON-4918
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
diff --git a/test/gridfs/delete.json b/test/gridfs/delete.json
|
||||
index 277b9ed7..9a9b22fc 100644
|
||||
--- a/test/gridfs/delete.json
|
||||
+++ b/test/gridfs/delete.json
|
||||
@@ -497,7 +497,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -650,7 +650,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
diff --git a/test/gridfs/download.json b/test/gridfs/download.json
|
||||
index f0cb8517..67658ac5 100644
|
||||
--- a/test/gridfs/download.json
|
||||
+++ b/test/gridfs/download.json
|
||||
@@ -338,7 +338,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -370,7 +370,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -402,7 +402,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -471,7 +471,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -514,7 +514,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
diff --git a/test/gridfs/downloadByName.json b/test/gridfs/downloadByName.json
|
||||
index 7b20933c..45abaf7b 100644
|
||||
--- a/test/gridfs/downloadByName.json
|
||||
+++ b/test/gridfs/downloadByName.json
|
||||
@@ -290,7 +290,7 @@
|
||||
"filename": "xyz"
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -306,7 +306,7 @@
|
||||
"revision": 999
|
||||
},
|
||||
"expectError": {
|
||||
- "isError": true
|
||||
+ "isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -66,6 +66,7 @@ from bson import SON, json_util
|
||||
from bson.codec_options import DEFAULT_CODEC_OPTIONS
|
||||
from bson.objectid import ObjectId
|
||||
from gridfs import AsyncGridFSBucket, GridOut, NoFile
|
||||
from gridfs.errors import CorruptGridFile
|
||||
from pymongo import ASCENDING, AsyncMongoClient, CursorType, _csot
|
||||
from pymongo.asynchronous.change_stream import AsyncChangeStream
|
||||
from pymongo.asynchronous.client_session import AsyncClientSession, TransactionOptions, _TxnState
|
||||
@ -613,6 +614,8 @@ class UnifiedSpecTestMixinV1(AsyncIntegrationTest):
|
||||
# Connection errors are considered client errors.
|
||||
if isinstance(error, ConnectionFailure):
|
||||
self.assertNotIsInstance(error, NotPrimaryError)
|
||||
elif isinstance(error, CorruptGridFile):
|
||||
pass
|
||||
elif isinstance(error, (InvalidOperation, ConfigurationError, EncryptionError, NoFile)):
|
||||
pass
|
||||
else:
|
||||
|
||||
@ -497,7 +497,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -650,7 +650,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@ -338,7 +338,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -370,7 +370,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -402,7 +402,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -471,7 +471,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -514,7 +514,7 @@
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -290,7 +290,7 @@
|
||||
"filename": "xyz"
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -306,7 +306,7 @@
|
||||
"revision": 999
|
||||
},
|
||||
"expectError": {
|
||||
"isError": true
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
179
test/gridfs/rename.json
Normal file
179
test/gridfs/rename.json
Normal file
@ -0,0 +1,179 @@
|
||||
{
|
||||
"description": "gridfs-rename",
|
||||
"schemaVersion": "1.0",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "gridfs-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"bucket": {
|
||||
"id": "bucket0",
|
||||
"database": "database0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "bucket0_files_collection",
|
||||
"database": "database0",
|
||||
"collectionName": "fs.files"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "bucket0_chunks_collection",
|
||||
"database": "database0",
|
||||
"collectionName": "fs.chunks"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "fs.files",
|
||||
"databaseName": "gridfs-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"$oid": "000000000000000000000001"
|
||||
},
|
||||
"length": 0,
|
||||
"chunkSize": 4,
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"filename": "filename",
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"_id": {
|
||||
"$oid": "000000000000000000000002"
|
||||
},
|
||||
"length": 0,
|
||||
"chunkSize": 4,
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"filename": "filename",
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"collectionName": "fs.chunks",
|
||||
"databaseName": "gridfs-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"$oid": "000000000000000000000001"
|
||||
},
|
||||
"files_id": {
|
||||
"$oid": "000000000000000000000002"
|
||||
},
|
||||
"n": 0,
|
||||
"data": {
|
||||
"$binary": {
|
||||
"base64": "",
|
||||
"subType": "00"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "rename by id",
|
||||
"operations": [
|
||||
{
|
||||
"name": "rename",
|
||||
"object": "bucket0",
|
||||
"arguments": {
|
||||
"id": {
|
||||
"$oid": "000000000000000000000001"
|
||||
},
|
||||
"newFilename": "newfilename"
|
||||
}
|
||||
}
|
||||
],
|
||||
"outcome": [
|
||||
{
|
||||
"collectionName": "fs.files",
|
||||
"databaseName": "gridfs-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"$oid": "000000000000000000000001"
|
||||
},
|
||||
"length": 0,
|
||||
"chunkSize": 4,
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"filename": "newfilename",
|
||||
"metadata": {}
|
||||
},
|
||||
{
|
||||
"_id": {
|
||||
"$oid": "000000000000000000000002"
|
||||
},
|
||||
"length": 0,
|
||||
"chunkSize": 4,
|
||||
"uploadDate": {
|
||||
"$date": "1970-01-01T00:00:00.000Z"
|
||||
},
|
||||
"filename": "filename",
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"collectionName": "fs.chunks",
|
||||
"databaseName": "gridfs-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": {
|
||||
"$oid": "000000000000000000000001"
|
||||
},
|
||||
"files_id": {
|
||||
"$oid": "000000000000000000000002"
|
||||
},
|
||||
"n": 0,
|
||||
"data": {
|
||||
"$binary": {
|
||||
"base64": "",
|
||||
"subType": "00"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "rename when file id does not exist",
|
||||
"operations": [
|
||||
{
|
||||
"name": "rename",
|
||||
"object": "bucket0",
|
||||
"arguments": {
|
||||
"id": {
|
||||
"$oid": "000000000000000000000003"
|
||||
},
|
||||
"newFilename": "newfilename"
|
||||
},
|
||||
"expectError": {
|
||||
"isClientError": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -65,6 +65,7 @@ from bson import SON, json_util
|
||||
from bson.codec_options import DEFAULT_CODEC_OPTIONS
|
||||
from bson.objectid import ObjectId
|
||||
from gridfs import GridFSBucket, GridOut, NoFile
|
||||
from gridfs.errors import CorruptGridFile
|
||||
from pymongo import ASCENDING, CursorType, MongoClient, _csot
|
||||
from pymongo.driver_info import DriverInfo
|
||||
from pymongo.encryption_options import _HAVE_PYMONGOCRYPT
|
||||
@ -612,6 +613,8 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
|
||||
# Connection errors are considered client errors.
|
||||
if isinstance(error, ConnectionFailure):
|
||||
self.assertNotIsInstance(error, NotPrimaryError)
|
||||
elif isinstance(error, CorruptGridFile):
|
||||
pass
|
||||
elif isinstance(error, (InvalidOperation, ConfigurationError, EncryptionError, NoFile)):
|
||||
pass
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user