-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_runtime_repo_tools.py
More file actions
34 lines (24 loc) · 887 Bytes
/
Copy pathtest_runtime_repo_tools.py
File metadata and controls
34 lines (24 loc) · 887 Bytes
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
import sys
import unittest
from pathlib import Path
from uuid import uuid4
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from runtime.tools import repo_tool # noqa: E402
def _sandbox_root() -> Path:
root = ROOT / "runs" / "tmp-tests" / uuid4().hex
root.mkdir(parents=True, exist_ok=True)
return root
class RuntimeRepoToolTests(unittest.TestCase):
def test_git_status_from_repo(self) -> None:
output = repo_tool.git_status()
self.assertIsInstance(output, str)
def test_git_diff_from_repo(self) -> None:
output = repo_tool.git_diff("README.md")
self.assertIsInstance(output, str)
def test_git_status_requires_repo(self) -> None:
root = _sandbox_root()
with self.assertRaises(ValueError):
repo_tool.git_status(root=root)
if __name__ == "__main__":
unittest.main()