Repository: gouline/dbt-metabase (language: python)

Issue:
Restructure models for better readability
- Rename `MetabaseClient` to `DbtMetabase` core
- Separate models and exposures command logic into separate mixins
- Make unit tests consistent with extracted mocks
- Format JSON fixtures to make them readable
- Unify defaults between CLI and programmatic API


Discussion / hints:

Fix patch:
diff --git a/dbtmetabase/__main__.py b/dbtmetabase/__main__.py
index 4419f52..9bd2061 100644
--- a/dbtmetabase/__main__.py
+++ b/dbtmetabase/__main__.py
@@ -10,7 +10,7 @@
 from ._format import click_list_option_kwargs, setup_logging
 from .core import DbtMetabase
 from .core_exposures import ExposuresExtractorMixin
-from .core_model import ModelsExporterMixin
+from .core_models import ModelsExporterMixin
 from .interface import Filter
 
 
diff --git a/dbtmetabase/core.py b/dbtmetabase/core.py
index bfed2b9..c695987 100644
--- a/dbtmetabase/core.py
+++ b/dbtmetabase/core.py
@@ -8,7 +8,7 @@
 from requests.adapters import HTTPAdapter, Retry
 
 from .core_exposures import ExposuresExtractorMixin
-from .core_model import ModelsExporterMixin
+from .core_models import ModelsExporterMixin
 from .interface import MetabaseArgumentError
 from .manifest import Manifest, Model
 
diff --git a/dbtmetabase/core_model.py b/dbtmetabase/core_models.py
similarity index 100%
rename from dbtmetabase/core_model.py
rename to dbtmetabase/core_models.py


Test patch:
diff --git a/tests/_mocks.py b/tests/_mocks.py
index f65a7b0..f3d947a 100644
--- a/tests/_mocks.py
+++ b/tests/_mocks.py
@@ -12,7 +12,7 @@
 TMP_PATH = Path("tests") / "tmp"
 
 
-class MockCore(DbtMetabase):
+class MockDbtMetabase(DbtMetabase):
     def __init__(self):
         super().__init__(
             manifest_path=Path("tests") / "fixtures" / "manifest.json",
diff --git a/tests/test_core_exposures.py b/tests/test_core_exposures.py
index 147742d..aee1e6d 100644
--- a/tests/test_core_exposures.py
+++ b/tests/test_core_exposures.py
@@ -6,13 +6,13 @@
 
 import yaml
 
-from ._mocks import FIXTURES_PATH, TMP_PATH, MockCore
+from ._mocks import FIXTURES_PATH, TMP_PATH, MockDbtMetabase
 
 
 class TestExposures(unittest.TestCase):
     def setUp(self):
         TMP_PATH.mkdir(exist_ok=True)
-        self.core = MockCore()
+        self.client = MockDbtMetabase()
 
     def _assert_exposures(self, expected_path: Path, actual_path: Path):
         with open(expected_path, encoding="utf-8") as f:
@@ -28,7 +28,7 @@ def _assert_exposures(self, expected_path: Path, actual_path: Path):
     def test_exposures(self):
         fixtures_path = FIXTURES_PATH / "exposure" / "default"
         output_path = TMP_PATH / "exposure" / "default"
-        self.core.extract_exposures(
+        self.client.extract_exposures(
             output_path=str(output_path),
             output_grouping=None,
         )
@@ -41,7 +41,7 @@ def test_exposures(self):
     def test_exposures_collection_grouping(self):
         fixtures_path = FIXTURES_PATH / "exposure" / "collection"
         output_path = TMP_PATH / "exposure" / "collection"
-        self.core.extract_exposures(
+        self.client.extract_exposures(
             output_path=str(output_path),
             output_grouping="collection",
         )
@@ -58,7 +58,7 @@ def test_exposures_collection_grouping(self):
     def test_exposures_grouping_type(self):
         fixtures_path = FIXTURES_PATH / "exposure" / "type"
         output_path = TMP_PATH / "exposure" / "type"
-        self.core.extract_exposures(
+        self.client.extract_exposures(
             output_path=str(output_path),
             output_grouping="type",
         )
diff --git a/tests/test_core_models.py b/tests/test_core_models.py
index a604b75..f675dec 100644
--- a/tests/test_core_models.py
+++ b/tests/test_core_models.py
@@ -2,16 +2,16 @@
 
 import unittest
 
-from ._mocks import MockCore
+from ._mocks import MockDbtMetabase
 
 
 class TestModels(unittest.TestCase):
     def setUp(self):
-        self.core = MockCore()
-        self.core._ModelsExporterMixin__SYNC_PERIOD = 1  # type: ignore
+        self.client = MockDbtMetabase()
+        self.client._ModelsExporterMixin__SYNC_PERIOD = 1  # type: ignore
 
     def test_export(self):
-        self.core.export_models(
+        self.client.export_models(
             metabase_database="unit_testing",
             skip_sources=True,
             sync_timeout=0,
@@ -28,7 +28,7 @@ def test_build_lookups(self):
             "PUBLIC.STG_ORDERS",
             "PUBLIC.STG_PAYMENTS",
         ]
-        actual_tables = self.core._ModelsExporterMixin__get_tables(database_id="2")  # type: ignore
+        actual_tables = self.client._ModelsExporterMixin__get_tables(database_id="2")  # type: ignore
         self.assertEqual(expected_tables, list(actual_tables.keys()))
 
         expected_columns = [