1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14+ import sys
1415import unittest
16+
17+ sys .path [0 :0 ] = ["" ]
18+
19+ from test import IntegrationTest
1520from test .unified_format import UnifiedSpecTestMixinV1
1621
1722
18- class TestCreateEntities (unittest . TestCase ):
23+ class TestCreateEntities (IntegrationTest ):
1924 def test_store_events_as_entities (self ):
2025 self .scenario_runner = UnifiedSpecTestMixinV1 ()
2126 spec = {
@@ -91,7 +96,7 @@ def test_store_all_others_as_entities(self):
9196 {
9297 "name" : "insertOne" ,
9398 "object" : "collection0" ,
94- "arguments" : {"document" : {"_id" : 1 , "x" : 44 }},
99+ "arguments" : {"document" : {"_id" : 2 , "x" : 44 }},
95100 },
96101 ],
97102 },
@@ -101,15 +106,19 @@ def test_store_all_others_as_entities(self):
101106 ],
102107 }
103108
109+ self .client .dat .dat .delete_many ({})
104110 self .scenario_runner .TEST_SPEC = spec
105111 self .scenario_runner .setUp ()
106112 self .scenario_runner .run_scenario (spec ["tests" ][0 ])
107113 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