forked from callmesora/llmops-python-package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_scripts.py
57 lines (45 loc) · 1.39 KB
/
test_scripts.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
# %% IMPORTS
# %% FUNCTIONS
# %% SCRIPTS
# def test_schema(capsys: pc.CaptureFixture[str]) -> None:
# # given
# args = ["prog", "--schema"]
# # when
# scripts.main(args)
# captured = capsys.readouterr()
# # then
# assert captured.err == "", "Captured error should be empty!"
# assert json.loads(captured.out), "Captured output should be a JSON!"
# @pytest.mark.parametrize(
# "scenario",
# [
# "valid",
# pytest.param(
# "invalid",
# marks=pytest.mark.xfail(
# reason="Invalid config.",
# raises=pdt.ValidationError,
# ),
# ),
# ],
# )
# def test_main(scenario: str, confs_path: str, extra_config: str) -> None:
# # given
# folder = os.path.join(confs_path, scenario)
# confs = list(sorted(os.listdir(folder)))
# # when
# for conf in confs: # one job per config
# config = os.path.join(folder, conf)
# argv = [config, "-e", extra_config]
# status = scripts.main(argv=argv)
# # then
# assert status == 0, f"Job should succeed for config: {config}"
# def test_main__no_configs() -> None:
# # given
# argv: list[str] = []
# # when
# with pytest.raises(RuntimeError) as error:
# scripts.main(argv)
# # then
# assert error.match("No configs provided."), "RuntimeError should be raised!"
# %%