Exemplo n.º 1
0
def test_check_ok(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.return_value = "FOO"
    result, message = web.check()
    urlopen.assert_called_with(EXAMPLE_URL)
    ok_(result)
    ok_("is available" in message)
Exemplo n.º 2
0
def test_check_ok(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.return_value = "FOO"
    result, message = web.check()
    urlopen.assert_called_with(EXAMPLE_URL)
    ok_(result)
    ok_("is available" in message)
Exemplo n.º 3
0
def test_check_statuses(urlopen):
    web = WebServiceChecker(EXAMPLE_URL, statuses=[420])
    urlopen.side_effect = urllib.error.HTTPError(EXAMPLE_URL, 420, "HTTP ERROR HAPPENED", None, None)
    result, message = web.check()
    ok_(result)
    ok_("is available" in message)
    ok_("[420]" in message)
Exemplo n.º 4
0
def test_check_httperror(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.side_effect = urllib.error.HTTPError(EXAMPLE_URL, 420,
                                                 "HTTP ERROR HAPPENED", None,
                                                 None)
    result, message = web.check()
    ok_(not result)
    ok_("[420]" in message)
Exemplo n.º 5
0
def test_check_statuses(urlopen):
    web = WebServiceChecker(EXAMPLE_URL, statuses=[420])
    urlopen.side_effect = urllib.error.HTTPError(EXAMPLE_URL, 420,
                                                 "HTTP ERROR HAPPENED", None,
                                                 None)
    result, message = web.check()
    ok_(result)
    ok_("is available" in message)
    ok_("[420]" in message)
Exemplo n.º 6
0
def test_check_unhandled(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.side_effect = IOError("Whoops")
    result, message = web.check()
    ok_(not result)
    ok_("Unhandled error: " in message)
Exemplo n.º 7
0
def test_check_urlerror(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.side_effect = urllib.error.URLError("URL ERROR HAPPENED")
    result, message = web.check()
    ok_(not result)
    ok_("URL ERROR HAPPENED" in message)
Exemplo n.º 8
0
def test_init_prefixless():
    web = WebServiceChecker("example.com")
    eq_(web._url, "http://example.com")
Exemplo n.º 9
0
def test_init():
    web = WebServiceChecker(EXAMPLE_URL)
    eq_(WebServiceChecker.checker_name, "web")
    eq_(web._url, EXAMPLE_URL)
Exemplo n.º 10
0
def test_check_unhandled(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.side_effect = IOError("Whoops")
    result, message = web.check()
    ok_(not result)
    ok_("Unhandled error: " in message)
Exemplo n.º 11
0
def test_check_urlerror(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.side_effect = urllib.error.URLError("URL ERROR HAPPENED")
    result, message = web.check()
    ok_(not result)
    ok_("URL ERROR HAPPENED" in message)
Exemplo n.º 12
0
def test_check_httperror(urlopen):
    web = WebServiceChecker(EXAMPLE_URL)
    urlopen.side_effect = urllib.error.HTTPError(EXAMPLE_URL, 420, "HTTP ERROR HAPPENED", None, None)
    result, message = web.check()
    ok_(not result)
    ok_("[420]" in message)