41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
class NewDeviceCliTests(unittest.TestCase):
|
|
def test_cli_generates_json_and_env_files(self):
|
|
with tempfile.TemporaryDirectory() as tmp:
|
|
out_dir = Path(tmp) / "devices"
|
|
result = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"tools/new_device.py",
|
|
"--count",
|
|
"2",
|
|
"--out-dir",
|
|
str(out_dir),
|
|
"--seed",
|
|
"1",
|
|
"--env",
|
|
"--force",
|
|
],
|
|
check=False,
|
|
cwd=Path(__file__).resolve().parents[1],
|
|
text=True,
|
|
capture_output=True,
|
|
)
|
|
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
self.assertTrue((out_dir / "device_001.json").exists())
|
|
self.assertTrue((out_dir / "device_001.env").exists())
|
|
self.assertTrue((out_dir / "device_002.json").exists())
|
|
self.assertTrue((out_dir / "device_002.env").exists())
|
|
self.assertIn("[OK]", result.stdout)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|