-
Notifications
You must be signed in to change notification settings - Fork 8
/
test_build.py
78 lines (59 loc) · 2.31 KB
/
test_build.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
import os
from pathlib import Path
import pytest
from packse import __development_base_path__
from packse.scenario import load_scenario, scenario_hash
from .common import snapshot_command
def test_build_no_target(snapshot):
assert snapshot_command(["build"]) == snapshot
def test_build_target_does_not_exist(snapshot):
assert snapshot_command(["build", "foo"]) == snapshot
def test_build_invalid_target(snapshot, tmpcwd):
target = tmpcwd / "test.json"
target.touch()
assert snapshot_command(["build", str(target)]) == snapshot
@pytest.mark.usefixtures("tmpcwd")
def test_build_example(snapshot):
target = __development_base_path__ / "scenarios" / "examples" / "example.json"
assert (
snapshot_command(
["build", str(target)], snapshot_filesystem=True, snapshot_stderr=False
)
== snapshot
)
@pytest.mark.usefixtures("tmpcwd")
def test_build_example_short_names(snapshot):
target = __development_base_path__ / "scenarios" / "examples" / "example.json"
assert (
snapshot_command(
["build", str(target), "--short-names"],
snapshot_filesystem=True,
snapshot_stderr=False,
)
== snapshot
)
@pytest.mark.usefixtures("tmpcwd")
@pytest.mark.usefixtures("tmpenviron")
def test_build_example_with_seed(snapshot):
target = __development_base_path__ / "scenarios" / "examples" / "example.json"
os.environ["PACKSE_VERSION_SEED"] = "foo"
assert (
snapshot_command(
["build", str(target)], snapshot_filesystem=True, snapshot_stderr=False
)
== snapshot
)
@pytest.mark.usefixtures("tmpcwd")
def test_build_example_already_exists(snapshot):
target = __development_base_path__ / "scenarios" / "examples" / "example.json"
scenario = load_scenario(target)
name = f"{scenario.name}-{scenario_hash(scenario)}"
(Path.cwd() / "build" / name).mkdir(parents=True)
assert snapshot_command(["build", target], snapshot_filesystem=True) == snapshot
@pytest.mark.usefixtures("tmpcwd")
def test_build_example_already_exists_with_rm_flag(snapshot):
target = __development_base_path__ / "scenarios" / "examples" / "example.json"
(Path(".") / "build").mkdir()
assert (
snapshot_command(["build", target, "--rm"], snapshot_stderr=False) == snapshot
)