|
| 1 | +from vax_suppliers import TestPair |
| 2 | +from constants import ActionFlag |
| 3 | +from utils import BusRowResult, InfResult |
| 4 | +from utils import poll_destination |
| 5 | + |
| 6 | + |
| 7 | +class TestAction: |
| 8 | + def __init__(self, action: ActionFlag, unique_id: str = None, |
| 9 | + expected_result: BusRowResult = BusRowResult.SUCCESS): |
| 10 | + self.action = action |
| 11 | + self.unique_id = unique_id |
| 12 | + self.expected_result = expected_result |
| 13 | + |
| 14 | + def poll_destination(self, pending: bool) -> bool: |
| 15 | + # loop through keys in test (inf and bus) |
| 16 | + for ack_key in self.ack_keys.keys(): |
| 17 | + if not self.ack_keys[ack_key]: |
| 18 | + found_ack_key = poll_destination(self.file_name, ack_key) |
| 19 | + if found_ack_key: |
| 20 | + self.ack_keys[ack_key] = found_ack_key |
| 21 | + else: |
| 22 | + pending = True |
| 23 | + return pending |
| 24 | + |
| 25 | + |
| 26 | +scenarios = { |
| 27 | + "dev": [ |
| 28 | + { |
| 29 | + "name": "Successful Create", |
| 30 | + "ods_vax": TestPair.E8HA94_COVID19_CUD, |
| 31 | + "expected_result": InfResult.SUCCESS, |
| 32 | + "actions": [TestAction(ActionFlag.CREATE)], |
| 33 | + "description": "Successful Create" |
| 34 | + }, |
| 35 | + { |
| 36 | + "name": "Successful Update", |
| 37 | + "description": "Successful Create,Update", |
| 38 | + "ods_vax": TestPair.DPSFULL_COVID19_CRUDS, |
| 39 | + "expected_result": InfResult.SUCCESS, |
| 40 | + "actions": [TestAction(ActionFlag.CREATE), TestAction(ActionFlag.UPDATE)] |
| 41 | + }, |
| 42 | + { |
| 43 | + "name": "Successful Delete", |
| 44 | + "description": "Successful Create,Update, Delete", |
| 45 | + "ods_vax": TestPair.V0V8L_FLU_CRUDS, |
| 46 | + "expected_result": InfResult.SUCCESS, |
| 47 | + "actions": [TestAction(ActionFlag.CREATE), TestAction(ActionFlag.DELETE_LOGICAL)] |
| 48 | + }, |
| 49 | + { |
| 50 | + "name": "Failed Update", |
| 51 | + "description": "Failed Update - resource does not exist", |
| 52 | + "ods_vax": TestPair.V0V8L_3IN1_CRUDS, |
| 53 | + "expected_result": InfResult.FATAL_ERROR, |
| 54 | + "actions": [TestAction(ActionFlag.UPDATE, expected_result=BusRowResult.FATAL_ERROR)], |
| 55 | + "operation_outcome": "Immunization resource does not exist" |
| 56 | + }, |
| 57 | + { |
| 58 | + "name": "Failed Delete", |
| 59 | + "description": "Failed Delete - resource does not exist", |
| 60 | + "ods_vax": TestPair.X26_MMR_CRUDS, |
| 61 | + "expected_result": InfResult.FATAL_ERROR, |
| 62 | + "actions": [TestAction(ActionFlag.DELETE_LOGICAL, expected_result=BusRowResult.FATAL_ERROR)], |
| 63 | + "operation_outcome": "Immunization resource does not exist" |
| 64 | + }, |
| 65 | + { |
| 66 | + "name": "Create with 1252 char", |
| 67 | + "description": "Create with 1252 char", |
| 68 | + "ods_vax": TestPair.YGA_MENACWY_CRUDS, |
| 69 | + "expected_result": InfResult.SUCCESS, |
| 70 | + "actions": [TestAction(ActionFlag.CREATE)], |
| 71 | + "test_encoding": True |
| 72 | + } |
| 73 | + ], |
| 74 | + "ref": [] |
| 75 | + } |
0 commit comments