def test_http_errors(api_mock, mocker, statuses): client = Client( base_url='http://testrail/', username='******', password='******') def request_callback(request, context): status = statuses.pop(0) context.status_code = status return "[]" url = re.escape('http://testrail/index.php?/api/v2/get_projects') api_mock.register_uri( 'GET', re.compile(url), text=request_callback, complete_qs=True) mocker.patch('time.sleep') client.projects()
def test_http_errors(api_mock, mocker, statuses): client = Client(base_url='http://testrail/', username='******', password='******') def request_callback(request, uri, headers): status = statuses.pop(0) return (status, headers, "[]") url = re.escape('http://testrail/index.php?/api/v2/get_projects') httpretty.register_uri(httpretty.GET, re.compile(url), body=request_callback, match_querystring=True) mocker.patch('time.sleep') client.projects()
def client(api_mock): client = Client( base_url='http://testrail/', username='******', password='******') base = re.escape(client.base_url) api_mock.register_uri( 'GET', re.compile(base + r'get_project(s|/).*'), text=_testrail_callback('project'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_suite(s|/).*'), text=_testrail_callback('suite'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_case(s|/).*'), text=_testrail_callback('case'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_plan(s|/).*'), text=_testrail_callback('plan'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_run(s|/).*'), text=_testrail_callback('run'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_result(s|/).*'), text=_testrail_callback('result'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_status(es|/).*'), text=_testrail_callback('status'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_milestone(s|/).*'), text=_testrail_callback('milestone'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_config(s|/).*'), text=_testrail_callback('config'), complete_qs=True) api_mock.register_uri( 'GET', re.compile(base + r'get_test(s|/).*'), text=_testrail_callback('test'), complete_qs=True) return client