Example #1
0
def test_fetch_single_url(tmpdir, monkeypatch):

    monkeypatch.setattr("requests.get", lambda url, headers, stream: get(url, headers, stream))

    path = str(tmpdir)
    testcase_result = copy.copy(RESULT_STATUS_200_SHORT)
    testcase_result['file.path'] = os.path.join(path, URLS[SUCCESS_URL]['sha256'])

    fetcher = Fetcher(path)
    assert fetcher.fetch(SUCCESS_URL) == testcase_result
Example #2
0
def test_fetch_return_error_result(tmpdir, monkeypatch):

    monkeypatch.setattr("requests.get", lambda url, headers, stream: get(url, headers, stream))
    fetcher = Fetcher(str(tmpdir))
    assert fetcher.fetch(NONE_URL) == RESULT_STATUS_404_SHORT