forked from ExpDev07/coronavirus-tracker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli.py
More file actions
57 lines (41 loc) · 1.61 KB
/
test_cli.py
File metadata and controls
57 lines (41 loc) · 1.61 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import subprocess
import sys
import pytest
PYTHON_VERSION = float(f"{sys.version_info.major}.{sys.version_info.minor}")
def test_invoke_list():
"""Test invoke --list"""
return_code = subprocess.call("invoke --list", shell=True)
assert return_code == 0
@pytest.mark.skipif(reason="Minor marker differences", condition=PYTHON_VERSION != 3.8)
def test_requirements_txt():
"""Validate that requirements.txt and requirements-dev.txt
are up2date with Pipefile"""
temp_output_dir = "tests/temp_output"
req_test_file_path = "{}/test-requirements.txt".format(temp_output_dir)
req_dev_test_file_path = "{}/test-requirements-dev.txt".format(temp_output_dir)
return_code_0 = subprocess.call("mkdir -p {}".format(temp_output_dir), shell=True)
return_code_1 = subprocess.call(
"pipenv lock -r \
> {}".format(
req_test_file_path
),
shell=True,
)
return_code_2 = subprocess.call(
"pipenv lock -r --dev-only \
> {}".format(
req_dev_test_file_path
),
shell=True,
)
with open("requirements.txt") as file:
req_file = file.read()
with open("requirements-dev.txt") as file:
req_dev_file = file.read()
with open(req_test_file_path) as file:
req_test_file = file.read()
with open(req_dev_test_file_path) as file:
req_dev_test_file = file.read()
return_code_z = subprocess.call("rm -rf {}".format(temp_output_dir), shell=True)
assert req_file == req_test_file
assert req_dev_file == req_dev_test_file