-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest_linkstatus.py
More file actions
31 lines (24 loc) · 965 Bytes
/
test_linkstatus.py
File metadata and controls
31 lines (24 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import subprocess
from pathlib import Path
import pytest
BASE_DIR = Path(os.path.dirname(os.path.abspath(__file__)))
def test_linkstatus_command():
result = subprocess.run("linkstatus", stdout=subprocess.PIPE)
assert result.returncode == 1
assert "Source Not Found" in result.stdout.decode()
assert "Run 'linkstatus --help' for more information." in result.stdout.decode()
@pytest.mark.parametrize(
"file",
[BASE_DIR / "conftest.py", BASE_DIR / "data" / "text_file"],
ids=["no-link", "with-link"],
)
def test_linkstatus_command_with_source(file):
result = subprocess.run(["linkstatus", file], stdout=subprocess.PIPE)
data = result.stdout.decode().strip()
if file.name == "text_file":
assert result.returncode == 1
assert all([check in data for check in ["Links SKIP: 0", "Links DOWN: 1", "Links UP: 3"]])
else:
assert result.returncode == 0
assert data == "No link found"