65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from mais_humana.paths import (
|
|
assert_real_repo_name,
|
|
central_project_folder_name,
|
|
default_paths,
|
|
describe_paths,
|
|
expected_remote_url,
|
|
path_health,
|
|
path_health_markdown,
|
|
path_ready,
|
|
path_action_hint,
|
|
platform_relative,
|
|
)
|
|
from tests.helpers import make_tmp
|
|
|
|
|
|
class PathConventionTests(unittest.TestCase):
|
|
def test_default_paths_keep_real_repo_without_number(self) -> None:
|
|
paths = default_paths("G:/_codex-git")
|
|
self.assertEqual(paths.project_root.name, "tudo-para-ia-mais-humana")
|
|
self.assertIn("15_repo_tudo-para-ia-mais-humana", str(paths.central_folder))
|
|
self.assertEqual(paths.sqlite_path.name, "controle-semantico.sqlite")
|
|
|
|
def test_ensure_creates_expected_directories(self) -> None:
|
|
tmp = make_tmp()
|
|
paths = default_paths(tmp)
|
|
paths.ensure()
|
|
self.assertTrue(paths.project_data_dir.exists())
|
|
self.assertTrue(paths.orders_executive_dir.exists())
|
|
|
|
def test_real_repo_name_guard_rejects_numbered_folder(self) -> None:
|
|
with self.assertRaises(ValueError):
|
|
assert_real_repo_name(Path("15_repo_tudo-para-ia-mais-humana"))
|
|
assert_real_repo_name(Path("tudo-para-ia-mais-humana"))
|
|
|
|
def test_path_helpers_generate_institutional_names(self) -> None:
|
|
repo = Path("tudo-para-ia-mais-humana")
|
|
self.assertEqual(central_project_folder_name(repo), "15_repo_tudo-para-ia-mais-humana")
|
|
self.assertEqual(
|
|
expected_remote_url("admin/tudo-para-ia-mais-humana"),
|
|
"https://git.ami.app.br/admin/tudo-para-ia-mais-humana.git",
|
|
)
|
|
self.assertEqual(platform_relative(Path("a/b/c"), Path("a")), "b/c")
|
|
self.assertTrue(any(line.startswith("project_root=") for line in describe_paths(default_paths("G:/_codex-git"))))
|
|
|
|
def test_path_health_reports_existing_directories(self) -> None:
|
|
tmp = make_tmp()
|
|
paths = default_paths(tmp)
|
|
before = path_health(paths)
|
|
self.assertFalse(before["project_root_exists"])
|
|
paths.ensure()
|
|
after = path_health(paths)
|
|
self.assertTrue(after["project_root_exists"])
|
|
self.assertTrue(path_ready(paths))
|
|
self.assertEqual(path_action_hint(paths), "caminhos essenciais prontos")
|
|
self.assertIn("Path Health", path_health_markdown(paths))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|