Skip to content

Commit

Permalink
Tests for two other cases
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCurtis committed Jan 31, 2024
1 parent 090c478 commit bb5d079
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from shlex import split as shlex_split
from subprocess import Popen
from subprocess import Popen, run
from time import sleep
from unittest import TestCase

Expand All @@ -26,3 +26,41 @@ def test_simple_case(self):
# Because of the javascripty-nature of the app, we can
# only really inspect the status code.
self.assertEqual(response.status_code, 200)

def test_errors_if_both_demo_and_connection_string_included(self):
command = (
"fk-graph"
" --demo"
" --connection-string=\"sqlite+pysqlite:///:memory:\""
" --table=table_a"
" --primary-key=1"
)
completed_process = run(
shlex_split(command),
capture_output=True,
text=True,
timeout=5
)
self.assertEqual(completed_process.returncode, 2)
self.assertIn(
"Exactly one of --demo and --connection-string should be used.",
completed_process.stderr
)

def test_errors_if_neither_demo_or_connection_string_included(self):
command = (
"fk-graph"
" --table=table_a"
" --primary-key=1"
)
completed_process = run(
shlex_split(command),
capture_output=True,
text=True,
timeout=5
)
self.assertEqual(completed_process.returncode, 2)
self.assertIn(
"Exactly one of --demo and --connection-string should be used.",
completed_process.stderr
)

0 comments on commit bb5d079

Please sign in to comment.