Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename test example files for consistency #25

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typer.testing import CliRunner

from sqlsynthgen.main import app
from tests.examples import example_tables, expected_output
from tests.examples import example_orm, expected_ssg
from tests.utils import get_test_settings

runner = CliRunner()
Expand Down Expand Up @@ -121,25 +121,25 @@ def test_make_generators(self) -> None:
with patch("sqlsynthgen.main.make_generators_from_tables") as mock_make:
result = runner.invoke(
app,
["make-generators", "tests/examples/example_tables.py"],
["make-generators", "tests/examples/example_orm.py"],
catch_exceptions=False,
)

self.assertSuccess(result)
mock_make.assert_called_once_with(example_tables)
mock_make.assert_called_once_with(example_orm)

def test_create_tables(self) -> None:
"""Test the create-tables sub-command."""

with patch("sqlsynthgen.main.create_db_tables") as mock_create:
result = runner.invoke(
app,
["create-tables", "tests/examples/example_tables.py"],
["create-tables", "tests/examples/example_orm.py"],
catch_exceptions=False,
)

self.assertSuccess(result)
mock_create.assert_called_once_with(example_tables.metadata)
mock_create.assert_called_once_with(example_orm.metadata)

def test_create_data(self) -> None:
"""Test the create-data sub-command."""
Expand All @@ -149,13 +149,13 @@ def test_create_data(self) -> None:
app,
[
"create-data",
"tests/examples/example_tables.py",
"tests/examples/expected_output.py",
"tests/examples/example_orm.py",
"tests/examples/expected_ssg.py",
],
catch_exceptions=False,
)

self.assertSuccess(result)
mock_create_db_data.assert_called_once_with(
example_tables.metadata.sorted_tables, expected_output.sorted_generators
example_orm.metadata.sorted_tables, expected_ssg.sorted_generators
)
6 changes: 3 additions & 3 deletions tests/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest import TestCase

from sqlsynthgen import make
from tests.examples import example_tables
from tests.examples import example_orm


class MyTestCase(TestCase):
Expand All @@ -12,9 +12,9 @@ def test_make_generators_from_tables(self) -> None:
"""Check that we can make a generators file from a tables module."""

with open(
"tests/examples/expected_output.py", encoding="utf-8"
"tests/examples/expected_ssg.py", encoding="utf-8"
) as expected_output:
expected = expected_output.read()

actual = make.make_generators_from_tables(example_tables)
actual = make.make_generators_from_tables(example_orm)
self.assertEqual(expected, actual)