def test_outlook_action_http_minimal(self): action = ActionHttp(method="GET", url=URL) self.assertDictEqual(action.as_data(), { "type": "Action.Http", "method": "GET", "url": URL })
def test_outlook_action_http(self): action = ActionHttp(method="POST", url=URL, title="Action title", body="asdf", is_visible=False, headers=[ Header("Proxy-Authorization", "Basic YWxhZGRpbjpvcGVuc2VzYW1l"), Header("Connection", "close") ]) self.assertDictEqual( action.as_data(), { "type": "Action.Http", "title": "Action title", "method": "POST", "url": URL, "body": "asdf", "headers": [{ "name": "Proxy-Authorization", "value": "Basic YWxhZGRpbjpvcGVuc2VzYW1l" }, { "name": "Connection", "value": "close" }], "isVisible": False })
def test_outlook_action_http_set_body(self): action = ActionHttp(method="GET", url=URL) action.set_body("bar") self.assertDictEqual(action.as_data(), { "type": "Action.Http", "method": "GET", "url": URL, "body": "bar" })
def test_outlook_action_http_set_title(self): action = ActionHttp(method="GET", url=URL) action.set_title("Praesent a consectetur") self.assertDictEqual( action.as_data(), { "type": "Action.Http", "method": "GET", "url": URL, "title": "Praesent a consectetur" })
def test_outlook_action_http_add_headers_object(self): action = ActionHttp(method="GET", url=URL) action.add_headers(Header("Connection", "close")) self.assertDictEqual( action.as_data(), { "type": "Action.Http", "method": "GET", "url": URL, "headers": [{ "name": "Connection", "value": "close" }] })
def test_outlook_action_http_add_headers_as_list(self): action = ActionHttp(method="GET", url=URL) action.add_headers([ Header("Proxy-Authorization", "Basic YWxhZGRpbjpvcGVuc2VzYW1l"), Header("Connection", "close") ]) self.assertDictEqual( action.as_data(), { "type": "Action.Http", "method": "GET", "url": URL, "headers": [{ "name": "Proxy-Authorization", "value": "Basic YWxhZGRpbjpvcGVuc2VzYW1l" }, { "name": "Connection", "value": "close" }] })
def test_outlook_action_http_no_body(self): with self.assertRaisesMessage( CardException, "If method is POST body must be provided"): ActionHttp(method="POST", url=URL)
def test_outlook_action_http_invalid_method(self): with self.assertRaisesMessage( CardException, "Invalid method. Available methods are: {}".format(METHODS)): ActionHttp(method="invalid", url=URL)