def test_404(self): url = self.getURL("404") self.setupStep(http.GET(url)) self.expectLogfile('log', "URL: %s\n ------ Content ------\n404" % (url, )) self.expectLogfile('content', "404") self.expectOutcome(result=FAILURE, state_string="Status code: 404 (failure)") return self.runStep()
def test_header(self): url = self.getURL("header") self.setup_step(http.GET(url, headers={"X-Test": "True"})) self.expect_log_file( 'log', f"URL: {url}\nStatus: 200\n ------ Content ------\nTrue") self.expect_outcome(result=SUCCESS, state_string="Status code: 200") return self.run_step()
def test_basic(self): url = self.getURL() self.setupStep(http.GET(url)) self.expectLogfile('log', "URL: %s\nStatus: 200\n ------ Content ------\nOK" % (url, )) self.expectLogfile('content', "OK") self.expectOutcome(result=SUCCESS, state_string="Status code: 200") return self.runStep()
def test_redirect(self): url = self.getURL("redirect") self.setupStep(http.GET(url)) expected_log = ''' Redirected 1 times: URL: {0}/redirect ------ Content ------ <html> <head> <meta http-equiv="refresh" content="0;URL=/redirected-path"> </head> <body bgcolor="#FFFFFF" text="#000000"> <a href="/redirected-path">click here</a> </body> </html> ============================================================ URL: {0}/redirected-path Status: 200 ------ Content ------ OK'''.format(self.get_connection_string()) self.expectLogfile('log', expected_log) self.expectLogfile('content', "OK") self.expectOutcome(result=SUCCESS, state_string="Status code: 200") return self.runStep()
def test_header(self): url = self.getURL("header") self.setupStep(http.GET(url, headers={"X-Test": "True"})) self.expectLogfile( 'log', "URL: %s\nStatus: 200\n ------ Content ------\nTrue" % (url, )) self.expectOutcome(result=SUCCESS, state_string="Status code: 200") return self.runStep()
def test_params_renderable(self): url = self.getURL() self.setupStep(http.GET(url, params=properties.Property("x"))) self.properties.setProperty('x', {'param_1': 'param_1', 'param_2': 2}, 'here') self.expectLogfile('log', "URL: %s?param_1=param_1¶m_2=2\nStatus: 200\n ------ Content ------\nOK" % (url, )) self.expectLogfile('content', "OK") self.expectOutcome(result=SUCCESS, state_string="Status code: 200") return self.runStep()
def test_get(self): url = self.getURL() self.setup_step(http.GET(url)) self.expect_log_file( 'log', f"URL: {url}\nStatus: 200\n ------ Content ------\nOK") self.expect_log_file('content', "OK") self.expect_outcome(result=SUCCESS, state_string="Status code: 200") return self.run_step()
def test_404(self): url = self.getURL("404") self.setup_step(http.GET(url)) self.expect_log_file('log', f"URL: {url}\n ------ Content ------\n404") self.expect_log_file('content', "404") self.expect_outcome(result=FAILURE, state_string="Status code: 404 (failure)") return self.run_step()
def test_404(self): url = self.getURL("404") self.setupStep(http.GET(url)) self.expectLogfile('log', "URL: %s\n ------ Content ------\n404" % (url, )) self.expectLogfile('content', "404") self.expectOutcome(result=FAILURE, status_text=["Status", "code:", '404']) return self.runStep()
def test_connection_error(self): def throwing_request(*args, **kwargs): raise requests.exceptions.ConnectionError("failed to connect") with mock.patch.object(http.getSession(), 'request', throwing_request): url = self.getURL("path") self.setupStep(http.GET(url)) self.expectOutcome(result=FAILURE, state_string="Requested (failure)") return self.runStep()
def test_hidden_header(self): url = self.getURL("header") self.setup_step( http.GET(url, headers={"X-Test": "True"}, hide_request_headers=["X-Test"], hide_response_headers=["Content-Length"])) self.expect_log_file( 'log', f"URL: {url}\nStatus: 200\n ------ Content ------\nTrue") self.expect_outcome(result=SUCCESS, state_string="Status code: 200") yield self.run_step() self.assertIn("X-Test: <HIDDEN>", self.step.logs['log'].header) self.assertIn("Content-Length: <HIDDEN>", self.step.logs['log'].header)
def test_basic(self): url = self.getURL() self.setupStep(http.GET(url)) self.expectLogfile('log', "URL: %s\nStatus: 200\n ------ Content ------\nOK" % (url, )) self.expectOutcome(result=SUCCESS, status_text=["Requested"]) return self.runStep()