def test_process_request_fails_on_unknown_request(service: BaseService, scenarios_dir): request = MITMRequest( body='{"value": "whatever"}', headers=MITMHeaders({ 'Accept': ['application/json'], }), method='PUT', url='https://host_a.local/this/path/is/not/handled', ) with raises(NoMatchingRecording): service.process_request(request)
def test_should_replay_only_once(service: BaseService, scenarios_dir): interaction = service.get_interactions_for_active_scenario()[0] interaction.max_replays = 1 assert service.should_replay(interaction) request_1 = MITMRequest( headers=MITMHeaders({ 'Accept': ['application/json'], 'Accept-Encoding': ['gzip, deflate'], 'Connection': ['keep-alive'], 'User-Agent': ['python-requests/2.18.4'] }), method='GET', url='https://host_a.local/api', ) service.process_request(request_1) assert not service.should_replay(interaction)
def test_process_request(service: BaseService, request_: MITMRequest, response: MITMResponse, scenarios_dir): assert service.process_request(request_) == response