From 480e3f3875440848dfa5813fbcf3a7bd1fe55ea2 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Thu, 4 May 2023 14:50:02 -0400 Subject: [PATCH] Clean up the tests Add tests for __all__ public api definition Rename test modules for consistency --- tests/test_calc_batch_size.py | 9 +++++++++ tests/{test_enumfield.py => test_enum_field.py} | 6 ++++++ tests/{test_jsonfield.py => test_json_field.py} | 6 ++++++ tests/{test_pathfield.py => test_path_field.py} | 6 ++++++ tests/test_precision_float_field.py | 6 ++++++ tests/test_timedelta_field.py | 6 ++++++ 6 files changed, 39 insertions(+) rename tests/{test_enumfield.py => test_enum_field.py} (88%) rename tests/{test_jsonfield.py => test_json_field.py} (82%) rename tests/{test_pathfield.py => test_path_field.py} (92%) diff --git a/tests/test_calc_batch_size.py b/tests/test_calc_batch_size.py index 1569933..1d22ba8 100644 --- a/tests/test_calc_batch_size.py +++ b/tests/test_calc_batch_size.py @@ -8,6 +8,15 @@ import peewee_plus from .fixtures import fakedb +def test_public_api(): + """Test that the public API components are exposed via ``__all__``""" + + assert peewee_plus.calc_batch_size.__name__ in peewee_plus.__all__ + assert peewee_plus.flat_transaction.__name__ in peewee_plus.__all__ + assert "SQLITE_DEFAULT_VARIABLE_LIMIT" in peewee_plus.__all__ + assert "SQLITE_DEFAULT_PRAGMAS" in peewee_plus.__all__ + + def test_sqlite(fakedb): """Test the calculation of batch sizes on SQLite""" diff --git a/tests/test_enumfield.py b/tests/test_enum_field.py similarity index 88% rename from tests/test_enumfield.py rename to tests/test_enum_field.py index a29c5b1..1fb0bc7 100644 --- a/tests/test_enumfield.py +++ b/tests/test_enum_field.py @@ -11,6 +11,12 @@ import peewee_plus from .fixtures import fakedb +def test_public_api(): + """Test that the public API components are exposed via ``__all__``""" + + assert peewee_plus.EnumField.__name__ in peewee_plus.__all__ + + def test_enum(fakedb): """Test basic functionality of the enum field""" diff --git a/tests/test_jsonfield.py b/tests/test_json_field.py similarity index 82% rename from tests/test_jsonfield.py rename to tests/test_json_field.py index 0a45511..d19c648 100644 --- a/tests/test_jsonfield.py +++ b/tests/test_json_field.py @@ -11,6 +11,12 @@ import peewee_plus from .fixtures import fakedb +def test_public_api(): + """Test that the public API components are exposed via ``__all__``""" + + assert peewee_plus.JSONField.__name__ in peewee_plus.__all__ + + def test_json(fakedb): """Test basic usage of JSONField class""" diff --git a/tests/test_pathfield.py b/tests/test_path_field.py similarity index 92% rename from tests/test_pathfield.py rename to tests/test_path_field.py index f2fb3f3..9c85fae 100644 --- a/tests/test_pathfield.py +++ b/tests/test_path_field.py @@ -10,6 +10,12 @@ import peewee_plus from .fixtures import fakedb +def test_public_api(): + """Test that the public API components are exposed via ``__all__``""" + + assert peewee_plus.PathField.__name__ in peewee_plus.__all__ + + def test_conversion(fakedb): """Test basic usage of PathField for roundtrip compatibility""" diff --git a/tests/test_precision_float_field.py b/tests/test_precision_float_field.py index d5bea9a..039f34f 100644 --- a/tests/test_precision_float_field.py +++ b/tests/test_precision_float_field.py @@ -8,6 +8,12 @@ import peewee_plus from .fixtures import fakedb +def test_public_api(): + """Test that the public API components are exposed via ``__all__``""" + + assert peewee_plus.PrecisionFloatField.__name__ in peewee_plus.__all__ + + # There isn't anything we can really test here since this field implements # a MySQL-specific syntax and we test with SQLite. This test is here just # to ensure that the behavior is consistent with the normal FloatField when diff --git a/tests/test_timedelta_field.py b/tests/test_timedelta_field.py index 45637f2..f5496cc 100644 --- a/tests/test_timedelta_field.py +++ b/tests/test_timedelta_field.py @@ -11,6 +11,12 @@ import peewee_plus from .fixtures import fakedb +def test_public_api(): + """Test that the public API components are exposed via ``__all__``""" + + assert peewee_plus.TimedeltaField.__name__ in peewee_plus.__all__ + + def test_conversion(fakedb): """Test basic usage of PathField for roundtrip compatibility"""