コード例 #1
0
ファイル: test_network.py プロジェクト: zalun/glean
def test_invalid_filename():
    pings_dir = PingUploadWorker.storage_directory()
    pings_dir.mkdir()

    with (pings_dir / "ping").open("wb") as fd:
        fd.write(b"\n")

    assert PingUploadWorker._test_process_sync()

    assert 0 == len(list(pings_dir.iterdir()))
コード例 #2
0
ファイル: test_network.py プロジェクト: zalun/glean
def test_unknown_scheme():
    Glean._configuration.server_endpoint = "ftp://example.com/"

    pings_dir = PingUploadWorker.storage_directory()
    pings_dir.mkdir()

    with (pings_dir / str(uuid.uuid4())).open("wb") as fd:
        fd.write(b"/data/path/\n")
        fd.write(b"{}\n")

    assert False is PingUploadWorker._test_process_sync()
コード例 #3
0
ファイル: test_network.py プロジェクト: zalun/glean
def test_500_error(safe_httpserver):
    safe_httpserver.serve_content(b"", code=500)
    Glean._configuration.server_endpoint = safe_httpserver.url

    pings_dir = PingUploadWorker.storage_directory()
    pings_dir.mkdir()

    with (pings_dir / str(uuid.uuid4())).open("wb") as fd:
        fd.write(b"/data/path/\n")
        fd.write(b"{}\n")

    assert not PingUploadWorker._test_process_sync()

    assert 1 == len(list(pings_dir.iterdir()))

    assert 1 == len(safe_httpserver.requests)