Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions test/change_streams/unified/change-streams.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
}
}
]
}
]
}
15 changes: 10 additions & 5 deletions test/test_change_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
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)

Expand Down Expand Up @@ -1037,7 +1038,7 @@ def test_read_concern(self):
pass


class TestAllScenarios(unittest.TestCase):
class TestAllLegacyScenarios(unittest.TestCase):

@classmethod
@client_context.require_connection
Expand Down Expand Up @@ -1120,8 +1121,7 @@ def tearDown(self):


_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):
Expand Down Expand Up @@ -1215,7 +1215,7 @@ def run_scenario(self):


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:
Expand Down Expand Up @@ -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()