def test_HpdsBypass_Connection_func_help(self, fake_stdout): test_url = "http://endpoint.url/pic-sure/" test_token = "my-JWT-token" conn = PicSureHpds.BypassConnection(test_url, test_token) conn.help() sys.stdout = sys.__stdout__ # Reset redirect. Needed for it to work! captured = fake_stdout.getvalue() print("Captured:\n" + captured) self.assertTrue(len(captured) > 0)
def test_HpdsBypass_Connection_func_about(self, MockHttp): resp_headers = {"status": "200"} content = '{"test": "this is a test of bypass.about()"}' MockHttp.return_value = (resp_headers, content.encode("utf-8")) test_url = "http://endpoint.url/pic-sure/" test_token = "my-JWT-token" test_uuid = "my-test-uuid" conn = PicSureHpds.BypassConnection(test_url, test_token) conn.about(test_uuid) MockHttp.assert_called_with( uri=test_url + "info/" + test_uuid, method="POST", body="{}", headers={'Content-Type': 'application/json'})
def test_HpdsBypass_Connection_func_list(self, MockHttp): resp_headers = {"status": "200"} content = ["test-uuid-1", "test-uuid-2", "test-uuid-3"] json_content = json.dumps(content) MockHttp.return_value = (resp_headers, json_content.encode("utf-8")) test_url = "http://endpoint.url/pic-sure/" test_token = "my-JWT-token" test_uuid = "my-test-uuid" conn = PicSureHpds.BypassConnection(test_url, test_token) conn.list() MockHttp.assert_called_with( uri=test_url + "info", method="POST", body="{}", headers={'Content-Type': 'application/json'})