Example #1
0
 def test_reply_mfw(self):
     reply_func = self.function_dispatcher.get_function_by_name("reply")
     reply_obj = self.function_dispatcher.get_function_object(reply_func)  # type: Reply
     # Check MFW produces response
     response = reply_obj.passive_run(Function.EVENT_MESSAGE, "MFW",
                                      None, self.server, self.test_user, self.test_chan)
     assert "http" in response
     # Check multiple times
     for _ in range(10):
         response = reply_obj.passive_run(Function.EVENT_MESSAGE, "MFW",
                                          None, self.server, self.test_user, self.test_chan)
         assert "http" in response
         response_url = "http" + response.split("http")[1]
         page_request = urllib.request.Request(response_url)
         page_opener = urllib.request.build_opener()
         resp_data = page_opener.open(page_request).read()
         assert len(resp_data) > 0
         # Check upper case url
         response_url_upper = Commons.upper(response_url)
         page_request = urllib.request.Request(response_url_upper)
         page_opener = urllib.request.build_opener()
         resp_data_upper = page_opener.open(page_request).read()
         assert len(resp_data_upper) > 0
Example #2
0
 def test_upper(self):
     assert Commons.upper("test words") == "TEST WORDS"
     assert Commons.upper("test http://google.com url") == "TEST http://google.com URL"