Test project status command
This commit is contained in:
parent
4b5880cb36
commit
5fee87b3a2
2 changed files with 24 additions and 4 deletions
|
@ -43,13 +43,11 @@ def status(running_only):
|
|||
for process in project.processes:
|
||||
if running_only and not process.is_running:
|
||||
continue
|
||||
port = process.port
|
||||
pid = process.pid
|
||||
table.add_row(
|
||||
[
|
||||
click.style(process.ident, fg=process.colour),
|
||||
pid if pid else "",
|
||||
port if port else "",
|
||||
process.pid or "",
|
||||
process.port or "",
|
||||
]
|
||||
)
|
||||
click.echo(table.get_string(sortby="ident"))
|
||||
|
|
|
@ -28,3 +28,25 @@ class ProjectRunCLITestCase(BaseTestCase):
|
|||
result = self.run_cli(["project", "run", "pwd"], catch_exceptions=False)
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
self.assertEqual(result.stdout.strip(), str(self.project.root))
|
||||
|
||||
|
||||
class ProjectStatusCLITestCase(BaseTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.project = Project(self.EXAMPLE_DIR)
|
||||
|
||||
def test_shows_all_processes(self):
|
||||
with self.in_example_dir():
|
||||
result = self.run_cli(["project", "status"])
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
output = result.stdout
|
||||
for process in self.project.processes:
|
||||
self.assertIn(process.ident, output)
|
||||
|
||||
def test_only_shows_running_processes(self):
|
||||
with self.in_example_dir():
|
||||
result = self.run_cli(["project", "status", "--running-only"])
|
||||
self.assertEqual(result.exit_code, 0)
|
||||
output = result.stdout
|
||||
for process in self.project.processes:
|
||||
self.assertNotIn(process.ident, output)
|
||||
|
|
Reference in a new issue