def test_get_context_order_create(): context = get_context('routing-keys/order-service.auto.order.created.json') assert type(context) is CreateOrderContext
def test_get_context_bad_action(): with pytest.raises(KeyError): get_context('routing-keys/order-service.auto.order.creatd.json') with pytest.raises(KeyError): get_context('routing-keys/policy-service.auto.order.ac.json')
def test_get_context_bad_service(): with pytest.raises(KeyError): get_context('routing-keys/a.auto.order.created.json')
def test_get_context_policy_refuse(): context = get_context('routing-keys/policy-service.auto.policy.refused.json') assert type(context) is UpdatePolicyContext
def test_get_context_policy_create(): context = get_context('routing-keys/policy-service.auto.policy.created.json') assert type(context) is CreatePolicyContext
from argparse import ArgumentParser from Context import get_context if __name__ == '__main__': parser = ArgumentParser(description='Process events') parser.add_argument('file_path', type=str) file_path = parser.parse_args().file_path context = get_context(file_path) context.process()