diff --git a/catfish/project/__init__.py b/catfish/project/__init__.py new file mode 100644 index 0000000..132642a --- /dev/null +++ b/catfish/project/__init__.py @@ -0,0 +1,14 @@ +from dataclasses import dataclass +from pathlib import Path + + +@dataclass +class Project: + root: Path + + def __post_init__(self): + self.root = Path(self.root) + assert self.exists() + + def exists(self): + return self.root.exists() diff --git a/tests/__init__.py b/tests/__init__.py index 0f39144..ee7b914 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -20,6 +20,7 @@ from catfish.utils.sockets import create_base_socket_dir, delete_base_socket_dir class BaseTestCase(TestCase): DUMMY_EXE = os.path.join(os.path.dirname(__file__), "dummy_program.py") + EXAMPLE_DIR = os.path.join(os.path.dirname(__file__), "../example") def setUp(self): create_base_socket_dir() diff --git a/tests/test_project/test_project.py b/tests/test_project/test_project.py new file mode 100644 index 0000000..001a574 --- /dev/null +++ b/tests/test_project/test_project.py @@ -0,0 +1,15 @@ +from catfish.project import Project +from tests import BaseTestCase + + +class ProjectTestCase(BaseTestCase): + def setUp(self): + super().setUp() + self.project = Project(self.EXAMPLE_DIR) + + def test_exists(self): + self.assertTrue(self.project.exists()) + + def test_cant_create_nonexistent_directory(self): + with self.assertRaises(AssertionError): + Project("/nonexistent")