Exemplo n.º 1
0
    def test_http_context_singleton_clear(self):
        ctxt_singleton = HttpRequestContextSingleton.get_instance()
        ctxt_singleton.method = "POST"
        self.assertEqual("POST", ctxt_singleton.method)
        ctxt_singleton.clear()
        self.assertNotEqual("POST", ctxt_singleton.method)

        ctxt_singleton2 = HttpRequestContextSingleton.get_instance()
        self.assertNotEqual("POST", ctxt_singleton2.method)
Exemplo n.º 2
0
    def test_http_context_clear(self):
        ctxt_singleton = HttpRequestContextSingleton.get_instance()
        ctxt_singleton.method = "POST"
        self.assertEqual("POST", ctxt_singleton.method)
        ctxt_singleton.clear()
        self.assertNotEqual("POST", ctxt_singleton.method)

        ctxt_singleton2 = HttpRequestContextSingleton.get_instance()
        self.assertNotEqual("POST", ctxt_singleton2.method)
Exemplo n.º 3
0
    def test_http_context_fields_to_clear(self):
        ctxt_singleton = HttpRequestContextSingleton.get_instance()
        ctxt_singleton.fields_to_clear = ['proxy']

        ctxt_singleton.proxy = "http://localhost:8080"
        ctxt_singleton.method = "PUT"
        self.assertEqual("http://localhost:8080", ctxt_singleton.proxy)
        ctxt_singleton.clear()
        self.assertNotEqual("http://localhost:8080", ctxt_singleton.proxy)
        self.assertEqual("PUT", ctxt_singleton.method)

        ctxt_singleton2 = HttpRequestContextSingleton.get_instance()
        self.assertNotEqual("http://localhost:8080", ctxt_singleton2.proxy)
        self.assertEqual("PUT", ctxt_singleton2.method)
Exemplo n.º 4
0
    def test_http_context_singleton_fields_to_clear(self):
        ctxt_singleton = HttpRequestContextSingleton.get_instance()
        ctxt_singleton.fields_to_clear = ['proxy']

        ctxt_singleton.proxy = "http://localhost:8080"
        ctxt_singleton.method = "PUT"
        self.assertEqual("http://localhost:8080", ctxt_singleton.proxy)
        ctxt_singleton.clear()
        self.assertNotEqual("http://localhost:8080", ctxt_singleton.proxy)
        self.assertEqual("PUT", ctxt_singleton.method)

        ctxt_singleton2 = HttpRequestContextSingleton.get_instance()
        self.assertNotEqual("http://localhost:8080", ctxt_singleton2.proxy)
        self.assertEqual("PUT", ctxt_singleton2.method)
Exemplo n.º 5
0
def send_http_request_with_query_parameters(context, method):
    query_params = dict()
    for row in context.table:
        query_params[row["param_name"]] = row["param_value"]
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.method = method
    http_request_context.query_params = query_params
    context.api_response = api.http_request_from_context(http_request_context)
    http_request_context.clear()
Exemplo n.º 6
0
    def test_http_context_sigleton(self):
        ctxt_singleton = HttpRequestContextSingleton.get_instance()
        ctxt_singleton.method = "POST"

        ctxt_singleton2 = HttpRequestContextSingleton.get_instance()
        self.assertEqual(ctxt_singleton.method, ctxt_singleton2.method)
Exemplo n.º 7
0
def set_default_host(context, host):
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.host = host
Exemplo n.º 8
0
def send_http_request(context, method):
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.method = method
    context.api_response = api.http_request_from_context(http_request_context)
    http_request_context.clear()
Exemplo n.º 9
0
def set_body_files(context):
    files = dict()
    for row in context.table:
        files[row["param_name"]] = row["path_to_file"]
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.files = files
Exemplo n.º 10
0
def set_body_parameters(context):
    body_params = dict()
    for row in context.table:
        body_params[row["param_name"]] = row["param_value"]
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.body_params = body_params
Exemplo n.º 11
0
def set_headers(context):
    headers = dict()
    for row in context.table:
        headers[row["header_name"]] = row["header_value"]
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.headers = headers
Exemplo n.º 12
0
def set_11path_authorization(context, app_id, secret):
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.authentication_instances.append(X11PathsAuthentication(app_id=app_id, secret=secret))
Exemplo n.º 13
0
def set_authorization_basic(context, username, password):
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.authentication_instances.append(BasicAuthentication(username=username, password=password))
Exemplo n.º 14
0
def set_url_path_with_params(context, url_path_str_format):
    table_as_json = dict(context.table)
    url_path = url_path_str_format % table_as_json
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.url_path = url_path
Exemplo n.º 15
0
def set_url_path(context, url_path):
    http_request_context = HttpRequestContextSingleton.get_instance()
    http_request_context.url_path = url_path
Exemplo n.º 16
0
    def test_http_context_sigleton(self):
        ctxt_singleton = HttpRequestContextSingleton.get_instance()
        ctxt_singleton.method = "POST"

        ctxt_singleton2 = HttpRequestContextSingleton.get_instance()
        self.assertEqual(ctxt_singleton.method, ctxt_singleton2.method)