def validate(action, arguments): if action != "bitcoin_balance" or arguments != {"net": "test", "type": "segwit"}: raise ValueError("unsupported action") return {"net": "test", "type": "segwit"} assert validate("bitcoin_balance", {"net": "test", "type": "segwit"})["net"] == "test" try: validate("bitcoin_send", {}) except ValueError: pass else: raise AssertionError("unexpected action accepted")