forked from JPEWdev/shacl2code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli.py
More file actions
65 lines (50 loc) · 1.38 KB
/
Copy pathtest_cli.py
File metadata and controls
65 lines (50 loc) · 1.38 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
58
59
60
61
62
63
64
65
#
# Copyright (c) 2024 Joshua Watt
#
# SPDX-License-Identifier: MIT
import subprocess
import sys
from shacl2code import VERSION
from shacl2code.lang import LANGUAGES
def test_shacl2code_exists():
"""
Tests that the shacl2code program exists
"""
subprocess.run(["shacl2code", "--help"], check=True)
def test_lang_list():
"""
Tests that the reported language list matches the actual language list
"""
p = subprocess.run(
["shacl2code", "list", "--short"],
check=True,
stdout=subprocess.PIPE,
encoding="utf-8",
)
assert sorted(p.stdout.splitlines()) == sorted(LANGUAGES.keys())
p = subprocess.run(
["shacl2code", "list"],
check=True,
stdout=subprocess.PIPE,
encoding="utf-8",
)
langs = {}
for line in p.stdout.splitlines():
name, desc = line.split("-")
name = name.rstrip()
desc = desc.lstrip()
langs[name] = desc
assert langs == {k: v.HELP for k, v in LANGUAGES.items()}
def test_module_invocation():
subprocess.run([sys.executable, "-m", "shacl2code", "--help"], check=True)
def test_version():
"""
Tests that the version subcommand works
"""
p = subprocess.run(
["shacl2code", "version"],
check=True,
stdout=subprocess.PIPE,
encoding="utf-8",
)
assert p.stdout.rstrip() == VERSION