(self, spec, uri=None)
| 1473 | self._run_scenario(spec, uri) |
| 1474 | |
| 1475 | def _run_scenario(self, spec, uri=None): |
| 1476 | # maybe skip test manually |
| 1477 | self.maybe_skip_test(spec) |
| 1478 | |
| 1479 | # process test-level runOnRequirements |
| 1480 | run_on_spec = spec.get("runOnRequirements", []) |
| 1481 | if not self.should_run_on(run_on_spec): |
| 1482 | raise unittest.SkipTest("runOnRequirements not satisfied") |
| 1483 | |
| 1484 | # process skipReason |
| 1485 | skip_reason = spec.get("skipReason", None) |
| 1486 | if skip_reason is not None: |
| 1487 | raise unittest.SkipTest(f"{skip_reason}") |
| 1488 | |
| 1489 | # Kill all sessions after each test with transactions to prevent an open |
| 1490 | # transaction (from a test failure) from blocking collection/database |
| 1491 | # operations during test set up and tear down. |
| 1492 | for op in spec["operations"]: |
| 1493 | name = op["name"] |
| 1494 | if name == "startTransaction" or name == "withTransaction": |
| 1495 | self.addCleanup(self.kill_all_sessions) |
| 1496 | break |
| 1497 | |
| 1498 | # process createEntities |
| 1499 | self._uri = uri |
| 1500 | self.entity_map = EntityMapUtil(self) |
| 1501 | self.entity_map.create_entities_from_spec(self.TEST_SPEC.get("createEntities", []), uri=uri) |
| 1502 | self._cluster_time = None |
| 1503 | # process initialData |
| 1504 | if "initialData" in self.TEST_SPEC: |
| 1505 | self.insert_initial_data(self.TEST_SPEC["initialData"]) |
| 1506 | self._cluster_time = self.client._topology.max_cluster_time() |
| 1507 | self.entity_map.advance_cluster_times(self._cluster_time) |
| 1508 | |
| 1509 | if "expectLogMessages" in spec: |
| 1510 | expect_log_messages = spec["expectLogMessages"] |
| 1511 | self.assertTrue(expect_log_messages, "expectEvents must be non-empty") |
| 1512 | self.check_log_messages(spec["operations"], expect_log_messages) |
| 1513 | else: |
| 1514 | # process operations |
| 1515 | self.run_operations(spec["operations"]) |
| 1516 | |
| 1517 | # process expectEvents |
| 1518 | if "expectEvents" in spec: |
| 1519 | expect_events = spec["expectEvents"] |
| 1520 | self.assertTrue(expect_events, "expectEvents must be non-empty") |
| 1521 | self.check_events(expect_events) |
| 1522 | |
| 1523 | # process outcome |
| 1524 | self.verify_outcome(spec.get("outcome", [])) |
| 1525 | |
| 1526 | |
| 1527 | class UnifiedSpecTestMeta(type): |
no test coverage detected