コード例 #1
0
def test_noop(app, q):
    statvfs_calls = []

    def statvfs(path):
        statvfs_calls.append(path)

    with patch("os.statvfs", new=statvfs):
        status = check_disk_bytes_free(app, q)

    assert statvfs_calls == []
    assert status == []
コード例 #2
0
def test_ok():
    statvfs_calls = []

    def statvfs(path):
        statvfs_calls.append(path)
        return Stat()

    with patch("os.statvfs", new=statvfs):
        status = check_disk_bytes_free(App(), Queue())

    assert statvfs_calls == ["path"]
    assert status == []
コード例 #3
0
def test_error():
    statvfs_calls = []

    def statvfs(path):
        statvfs_calls.append(path)
        return Stat(0, 0)

    with patch("os.statvfs", new=statvfs):
        status = check_disk_bytes_free(App(), Queue())

    assert statvfs_calls == ["path"]
    assert len(status) == 1
    error = status.pop()
    assert error.id == "edge.checks.E001"
    assert error.level == 40
    assert error.msg == "disk bytes free below threshold"
コード例 #4
0
def test_warn():
    statvfs_calls = []

    def statvfs(path):
        statvfs_calls.append(path)
        raise FileNotFoundError()

    with patch("os.statvfs", new=statvfs):
        status = check_disk_bytes_free(App(), Queue())

    assert statvfs_calls == ["path"]
    assert len(status) == 1
    error = status.pop()
    assert error.id == "edge.checks.W001"
    assert error.level == 30
    assert error.msg == "queue path does not exist"