Add base project class
This commit is contained in:
parent
3bc8de98e6
commit
5997412b98
3 changed files with 30 additions and 0 deletions
14
catfish/project/__init__.py
Normal file
14
catfish/project/__init__.py
Normal file
|
@ -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()
|
|
@ -20,6 +20,7 @@ from catfish.utils.sockets import create_base_socket_dir, delete_base_socket_dir
|
||||||
|
|
||||||
class BaseTestCase(TestCase):
|
class BaseTestCase(TestCase):
|
||||||
DUMMY_EXE = os.path.join(os.path.dirname(__file__), "dummy_program.py")
|
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):
|
def setUp(self):
|
||||||
create_base_socket_dir()
|
create_base_socket_dir()
|
||||||
|
|
15
tests/test_project/test_project.py
Normal file
15
tests/test_project/test_project.py
Normal file
|
@ -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")
|
Reference in a new issue