-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathtest_generate_atomic.py
More file actions
47 lines (38 loc) · 1.35 KB
/
test_generate_atomic.py
File metadata and controls
47 lines (38 loc) · 1.35 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
import json
import os
import subprocess
from pathlib import Path
def test_generate_atomic(tmp_path: Path):
repo_root = Path(__file__).resolve().parents[2]
os.chdir(repo_root)
config_path = repo_root / "graphgen" / "configs" / "atomic_config.yaml"
output_dir = tmp_path / "output"
output_dir.mkdir(parents=True, exist_ok=True)
result = subprocess.run(
[
"python",
"-m",
"graphgen.generate",
"--config_file",
str(config_path),
"--output_dir",
str(output_dir),
],
capture_output=True,
text=True,
check=False,
)
assert result.returncode == 0, f"Script failed with error: {result.stderr}"
data_root = output_dir / "data" / "graphgen"
run_folder = sorted(data_root.iterdir(), key=lambda p: p.name, reverse=True)[0]
config_saved = run_folder / "config.yaml"
assert config_saved.exists(), f"{config_saved} not found"
json_files = list(run_folder.glob("*.json"))
assert json_files, f"No JSON output found in {run_folder}"
log_files = list(run_folder.glob("*.log"))
assert log_files, "No log file generated"
with open(json_files[0], "r", encoding="utf-8") as f:
data = json.load(f)
assert (
isinstance(data, list) and len(data) > 0
), "JSON output is empty or not a list"