11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
+ import sys
14
15
import unittest
16
+
17
+ sys .path [0 :0 ] = ["" ]
18
+
19
+ from test import IntegrationTest
15
20
from test .unified_format import UnifiedSpecTestMixinV1
16
21
17
22
18
- class TestCreateEntities (unittest . TestCase ):
23
+ class TestCreateEntities (IntegrationTest ):
19
24
def test_store_events_as_entities (self ):
20
25
self .scenario_runner = UnifiedSpecTestMixinV1 ()
21
26
spec = {
@@ -91,7 +96,7 @@ def test_store_all_others_as_entities(self):
91
96
{
92
97
"name" : "insertOne" ,
93
98
"object" : "collection0" ,
94
- "arguments" : {"document" : {"_id" : 1 , "x" : 44 }},
99
+ "arguments" : {"document" : {"_id" : 2 , "x" : 44 }},
95
100
},
96
101
],
97
102
},
@@ -101,15 +106,19 @@ def test_store_all_others_as_entities(self):
101
106
],
102
107
}
103
108
109
+ self .client .dat .dat .delete_many ({})
104
110
self .scenario_runner .TEST_SPEC = spec
105
111
self .scenario_runner .setUp ()
106
112
self .scenario_runner .run_scenario (spec ["tests" ][0 ])
107
113
self .scenario_runner .entity_map ["client0" ].close ()
108
- final_entity_map = self .scenario_runner .entity_map
109
- for entity in ["errors" , "failures" ]:
110
- self .assertIn (entity , final_entity_map )
111
- self .assertGreaterEqual (len (final_entity_map [entity ]), 0 )
112
- self .assertEqual (type (final_entity_map [entity ]), list )
113
- for entity in ["successes" , "iterations" ]:
114
- self .assertIn (entity , final_entity_map )
115
- self .assertEqual (type (final_entity_map [entity ]), int )
114
+ entity_map = self .scenario_runner .entity_map
115
+ self .assertEqual (len (entity_map ["errors" ]), 4 )
116
+ for error in entity_map ["errors" ]:
117
+ self .assertEqual (error ["type" ], "DuplicateKeyError" )
118
+ self .assertEqual (entity_map ["failures" ], [])
119
+ self .assertEqual (entity_map ["successes" ], 2 )
120
+ self .assertEqual (entity_map ["iterations" ], 5 )
121
+
122
+
123
+ if __name__ == "__main__" :
124
+ unittest .main ()
0 commit comments