Python 2548/add update description.truncated arrays field (#572)

This commit is contained in:
Prashant Mital 2021-03-02 11:06:56 -08:00 committed by GitHub
parent 20d5a9cf81
commit 4088c1cee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 126 additions and 5 deletions

View File

@ -0,0 +1,116 @@
{
"description": "change-streams",
"schemaVersion": "1.0",
"createEntities": [
{
"client": {
"id": "client0"
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "collection0"
}
}
],
"initialData": [
{
"collectionName": "collection0",
"databaseName": "database0",
"documents": []
}
],
"tests": [
{
"description": "Test array truncation",
"runOnRequirements": [
{
"minServerVersion": "4.7",
"topologies": [
"replicaset"
]
}
],
"operations": [
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1,
"array": [
"foo",
{
"a": "bar"
},
1,
2,
3
]
}
}
},
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": []
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "updateOne",
"object": "collection0",
"arguments": {
"filter": {
"_id": 1
},
"update": [
{
"$set": {
"array": [
"foo",
{
"a": "bar"
}
]
}
}
]
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "update",
"ns": {
"db": "database0",
"coll": "collection0"
},
"updateDescription": {
"updatedFields": {},
"removedFields": [],
"truncatedArrays": [
{
"field": "array",
"newSize": 2
}
]
}
}
}
]
}
]
}

View File

@ -43,6 +43,7 @@ from pymongo.read_concern import ReadConcern
from pymongo.write_concern import WriteConcern
from test import client_context, unittest, IntegrationTest
from test.unified_format import generate_test_classes
from test.utils import (
EventListener, WhiteListEventListener, rs_or_single_client, wait_until)
@ -1037,7 +1038,7 @@ class TestCollectionChangeStream(TestChangeStreamBase, APITestsMixin,
pass
class TestAllScenarios(unittest.TestCase):
class TestAllLegacyScenarios(unittest.TestCase):
@classmethod
@client_context.require_connection
@ -1120,8 +1121,7 @@ class TestAllScenarios(unittest.TestCase):
_TEST_PATH = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'change_streams'
)
os.path.dirname(os.path.realpath(__file__)), 'change_streams')
def camel_to_snake(camel):
@ -1215,7 +1215,7 @@ def create_test(scenario_def, test):
def create_tests():
for dirpath, _, filenames in os.walk(_TEST_PATH):
for dirpath, _, filenames in os.walk(os.path.join(_TEST_PATH, 'legacy')):
dirname = os.path.split(dirpath)[-1]
for filename in filenames:
@ -1251,11 +1251,16 @@ def create_tests():
str(test['description'].replace(" ", "_")))
new_test.__name__ = test_name
setattr(TestAllScenarios, new_test.__name__, new_test)
setattr(TestAllLegacyScenarios, new_test.__name__, new_test)
create_tests()
globals().update(generate_test_classes(
os.path.join(_TEST_PATH, 'unified'),
module=__name__,))
if __name__ == '__main__':
unittest.main()