-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_commandline.py
97 lines (69 loc) · 2.99 KB
/
test_commandline.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import os
import subprocess
from asekuro.common import _testfile
from asekuro.cli import clean, test
from click.testing import CliRunner
class TestPathHandlingLocal:
@classmethod
def setup_class(cls):
os.chdir("tests/notebooks")
@classmethod
def teardown_class(cls):
os.chdir("../..")
def test_tempfile_creation(self):
assert _testfile("foobar.ipynb") == "foobar-test.ipynb"
def test_good_nb(self):
status = subprocess.call(['asekuro', 'test', 'good-nb.ipynb'])
assert status == 0
def test_good_nb_meta(self):
status = subprocess.call(['asekuro', 'test', 'good-nb-metadata.ipynb'])
assert status == 0
def test_data_nb(self):
status = subprocess.call(['asekuro', 'test', 'data-nb.ipynb'])
assert status == 0
def test_commented_load(self):
status = subprocess.call(['asekuro', 'test', 'commented-load.ipynb'])
assert status == 0
def test_bad_bn(self):
status = subprocess.call(['asekuro', 'test', 'bad-nb.ipynb'])
assert status == 2
class TestCommandLineWorksWithPath:
def test_good_nb(self):
status = subprocess.call(['asekuro', 'test', 'tests/notebooks/good-nb.ipynb'])
assert status == 0
def test_data_nb(self):
status = subprocess.call(['asekuro', 'test', 'tests/notebooks/data-nb.ipynb'])
assert status == 0
def test_bad_bn(self):
status = subprocess.call(['asekuro', 'test', 'tests/notebooks/bad-nb.ipynb'])
assert status == 2
def test_good_nb_meta(self):
status = subprocess.call(['asekuro', 'test', 'tests/notebooks/good-nb-metadata.ipynb'])
assert status == 0
def test_good_nb_autoreload(self):
status = subprocess.call(['asekuro', 'test', 'tests/notebooks/nb-autoreload.ipynb'])
assert status == 0
class TestCheckCommands:
def test_good_nb(self):
status = subprocess.call(['asekuro', 'check', 'tests/notebooks/functions.ipynb', 'tests/functions-solution.py'])
assert status == 0
def test_clean_good_nb(self):
status = subprocess.call(['asekuro', 'check', 'tests/notebooks/functions.ipynb', 'tests/functions-solution-fail.py'])
assert status == 2
class TestCommandsWorkWithWildCards:
def test_clean_wildcard(self):
runner = CliRunner()
result = runner.invoke(clean, input='tests/notebooks/*.ipynb')
assert not result.exception
def test_multi_file(self):
runner = CliRunner()
result = runner.invoke(clean, input='tests/notebooks/data-nb.ipynb tests/notebooks/good-nb.ipynb')
assert not result.exception
def test_test_wildcard(self):
runner = CliRunner()
result = runner.invoke(test, input='tests/notebooks/good*.ipynb')
assert not result.exception
def test_test_multi_file(self):
runner = CliRunner()
result = runner.invoke(test, input='tests/notebooks/good-nb.ipynb tests/notebooks/good-nb-metadata.ipynb')
assert not result.exception