Skip to content

Commit 8b03e22

Browse files
author
Johannes Lichtenberger
committed
Update tests and TypedDicts to include path field in diff responses
SirixDB now emits a 'path' field in diff responses (insert, delete, replace, update) when PathSummary is enabled. This updates: 1. Test expectations to include the 'path' field 2. TypedDict definitions (InsertDiff, ReplaceDiff, UpdateDiff, DeleteDiff) to include 'path' as an optional field 3. Made TypedDicts use total=False since many fields are optional depending on resource configuration (PathSummary, DeweyIDs)
1 parent 4719b80 commit 8b03e22

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

pysirix/types.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,47 +45,69 @@ class Revision(TypedDict):
4545
revisionNumber: int
4646
revision: Union[List, Dict, str, int, float, None]
4747

48-
class InsertDiff(TypedDict):
48+
class InsertDiff(TypedDict, total=False):
4949
"""
5050
This type is available only in python 3.8+.
5151
Otherwise, defaults to ``dict``.
52+
53+
Fields ``path``, ``deweyID``, ``depth``, and ``data`` are optional depending
54+
on resource configuration (PathSummary and DeweyIDs).
5255
"""
5356

5457
nodeKey: int
5558
insertPositionNodeKey: int
5659
insertPosition: InsertPosition
60+
path: str
5761
deweyID: str
5862
depth: int
5963
type: str
6064
data: DataType
6165

62-
class ReplaceDiff(TypedDict):
66+
class ReplaceDiff(TypedDict, total=False):
6367
"""
6468
This type is available only in python 3.8+.
6569
Otherwise, defaults to ``dict``.
70+
71+
Fields ``path``, ``deweyID``, ``depth``, and ``data`` are optional depending
72+
on resource configuration (PathSummary and DeweyIDs).
6673
"""
6774

68-
nodeKey: int
69-
type: DataType
75+
oldNodeKey: int
76+
newNodeKey: int
77+
path: str
78+
deweyID: str
79+
depth: int
80+
type: str
7081
data: str
7182

72-
class UpdateDiff(TypedDict):
83+
class UpdateDiff(TypedDict, total=False):
7384
"""
7485
This type is available only in python 3.8+.
7586
Otherwise, defaults to ``dict``.
87+
88+
Fields ``path``, ``deweyID``, ``depth``, ``name``, ``type``, and ``value``
89+
are optional depending on the update type and resource configuration.
7690
"""
7791

7892
nodeKey: int
93+
path: str
94+
deweyID: str
95+
depth: int
96+
name: str
7997
type: DataType
8098
value: Union[str, int, float, bool, None]
8199

82-
class DeleteDiff(TypedDict):
100+
class DeleteDiff(TypedDict, total=False):
83101
"""
84102
This type is available only in python 3.8+.
85103
Otherwise, defaults to ``dict``.
104+
105+
Fields ``path``, ``deweyID``, and ``depth`` are optional depending
106+
on resource configuration (PathSummary and DeweyIDs).
86107
"""
87108

88109
nodeKey: int
110+
path: str
89111
deweyID: str
90112
depth: int
91113

tests/test_resource_sync.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def test_diff():
154154
"insertPosition": "asFirstChild",
155155
"insertPositionNodeKey": 1,
156156
"nodeKey": 2,
157+
"path": "/[0]",
157158
"type": "jsonFragment",
158159
}
159160
}

tests/test_sirix_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ async def test_diff():
261261
"insertPosition": "asFirstChild",
262262
"insertPositionNodeKey": 1,
263263
"nodeKey": 2,
264+
"path": "/[0]",
264265
"type": "jsonFragment",
265266
}
266267
}

0 commit comments

Comments
 (0)