def mock_contract_agency(monkeypatch, module_mocker, token_economics): monkeypatch.setattr(ContractAgency, 'get_agent', MockContractAgency.get_agent) module_mocker.patch.object(EconomicsFactory, 'get_economics', return_value=token_economics) mock_agency = MockContractAgency() yield mock_agency mock_agency.reset()
def mock_contract_agency(module_mocker, token_economics): # Patch module_mocker.patch.object(EconomicsFactory, 'get_economics', return_value=token_economics) # Monkeypatch # TODO: Use better tooling for this monkeypatch? get_agent = ContractAgency.get_agent get_agent_by_name = ContractAgency.get_agent_by_contract_name ContractAgency.get_agent = MockContractAgency.get_agent ContractAgency.get_agent_by_contract_name = MockContractAgency.get_agent_by_contract_name # Test yield MockContractAgency() # Restore the monkey patching ContractAgency.get_agent = get_agent ContractAgency.get_agent_by_contract_name = get_agent_by_name