Add base project class

This commit is contained in:
Jake Howard 2018-12-17 20:40:11 +00:00
parent 3bc8de98e6
commit 5997412b98
Signed by: jake
GPG key ID: 57AFB45680EDD477
3 changed files with 30 additions and 0 deletions

View 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()

View file

@ -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()

View 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")