This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
catfish/tests/test_project/test_project.py

55 lines
1.9 KiB
Python
Raw Normal View History

2018-12-18 20:16:34 +00:00
from catfish.project import DuplicateProcessException, Project, parse_procfile_processes
2018-12-17 20:40:11 +00:00
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")
2018-12-17 21:43:46 +00:00
def test_read_processes(self):
2018-12-18 20:16:34 +00:00
self.assertEqual(len(self.project.processes), 2)
web_process = self.project.processes[0]
self.assertEqual(web_process.name, "web")
self.assertEqual(web_process.command, "python -m http.server $PORT")
self.assertEqual(web_process.project, self.project)
bg_process = self.project.processes[1]
self.assertEqual(bg_process.name, "bg")
self.assertEqual(bg_process.command, "python src/dummy_program.py")
self.assertEqual(bg_process.project, self.project)
def test_get_process(self):
self.assertEqual(self.project.get_process("web").name, "web")
self.assertEqual(self.project.get_process("bg").name, "bg")
self.assertIsNone(self.project.get_process("nonexistent"))
2018-12-18 15:34:57 +00:00
def test_name(self):
2018-12-18 15:49:20 +00:00
self.assertEqual(self.project.name, "example")
2018-12-18 20:16:34 +00:00
2018-12-18 21:42:23 +00:00
def test_read_environment(self):
self.assertEqual(self.project.env["FOO"], "bar")
2018-12-18 20:16:34 +00:00
class ProcessTestCase(BaseTestCase):
def setUp(self):
super().setUp()
self.project = Project(self.EXAMPLE_DIR)
self.process = self.project.get_process("web")
def test_process_ident(self):
self.assertEqual(self.process.ident, "example:web")
def test_duplicate_procfile(self):
with self.assertRaises(DuplicateProcessException) as e:
list(parse_procfile_processes(self.project, ["web: 123.py", "web: 456.py"]))
self.assertEqual(str(e.exception), "web")