예제 #1
0
def test_valid_remote_http_response_should_yield_positive():
    opener_director = mock_opener_director()
    monitor = Monitor('http://google.com', opener_director=opener_director)
    response = monitor.ping()

    assert response
    assert httplib.OK == response.response_code
예제 #2
0
def test_not_found_should_yield_negative():
    opener_director = mock_opener_director(response_code=httplib.NOT_FOUND)
    monitor = Monitor('http://localhost:8000/404.html',
                      opener_director=opener_director)
    response = monitor.ping()

    assert not response
    assert httplib.NOT_FOUND == response.response_code
예제 #3
0
def test_valid_local_http_response_should_yield_positive():
    opener_director = mock_opener_director()
    monitor = Monitor('http://localhost:8000', opener_director=opener_director)

    response = monitor.ping()

    opener_director.open.assert_called_once_with('http://localhost:8000')

    assert response
    assert httplib.OK == response.response_code
예제 #4
0
 def __init__(self, urls):
     self.monitors = [Monitor(url) for url in urls]