Exemple #1
0
def test_reply_mfw(hallo_getter):
    hallo, test_server, test_channel, test_user = hallo_getter({"silly"})
    reply_func = hallo.function_dispatcher.get_function_by_name("reply")
    reply_obj = hallo.function_dispatcher.get_function_object(
        reply_func)  # type: Reply
    # Check MFW produces response
    response = reply_obj.passive_run(
        EventMessage(test_server, test_channel, test_user, "MFW"), hallo)
    assert "http" in response.text
    # Check multiple times
    for _ in range(10):
        response = reply_obj.passive_run(
            EventMessage(test_server, test_channel, test_user, "MFW"), hallo)
        assert "http" in response.text
        response_url = "http" + response.text.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
Exemple #2
0
def test_upper__with_url():
    assert Commons.upper(
        "test http://google.com url") == "TEST http://google.com URL"
Exemple #3
0
def test_upper():
    assert Commons.upper("test words") == "TEST WORDS"