示例#1
0
 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
     })
示例#2
0
 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
         })
示例#3
0
 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"
     })
示例#4
0
 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"
         })
示例#5
0
 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"
             }]
         })
示例#6
0
 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"
             }]
         })
示例#7
0
 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)
示例#8
0
 def test_outlook_action_http_invalid_method(self):
     with self.assertRaisesMessage(
             CardException,
             "Invalid method. Available methods are: {}".format(METHODS)):
         ActionHttp(method="invalid", url=URL)