/ backend / test_basic.py
test_basic.py
 1  #!/usr/bin/env python3
 2  """
 3  Basic tests for ci-dashboard backend.
 4  Ensures pytest has at least one test to collect.
 5  """
 6  
 7  
 8  def test_imports():
 9      """Verify core modules can be imported."""
10      import os
11      import json
12      assert os is not None
13      assert json is not None
14  
15  
16  def test_radicle_repos_json_valid():
17      """Verify radicle-repos.json is valid JSON with expected structure."""
18      import json
19      from pathlib import Path
20  
21      repos_file = Path(__file__).parent / "radicle-repos.json"
22      if repos_file.exists():
23          with open(repos_file) as f:
24              data = json.load(f)
25          assert isinstance(data, dict)
26          assert "repos" in data
27          # repos is a dict mapping repo names to RIDs
28          assert isinstance(data["repos"], dict)
29          # Each value should be a RID starting with "rad:"
30          for name, rid in data["repos"].items():
31              assert isinstance(name, str)
32              assert isinstance(rid, str)
33              assert rid.startswith("rad:"), f"RID for {name} should start with 'rad:'"
34  
35  
36  def test_python_files_syntax():
37      """Verify Python files have valid syntax."""
38      import ast
39      from pathlib import Path
40  
41      backend_dir = Path(__file__).parent
42      for py_file in backend_dir.glob("*.py"):
43          if py_file.name.startswith("test_"):
44              continue
45          with open(py_file) as f:
46              source = f.read()
47          # This will raise SyntaxError if invalid
48          ast.parse(source)