summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOliver Rice <github@oliverrice.com>2021-03-05 14:23:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-03-05 16:32:54 -0500
commit70115dc5d65e1f2e665d3b94cf7734184c3b96e2 (patch)
tree32dd25512a3cae5b11c26b2b07d06d784e434599 /tests
parentc3fc47dc998fcdbba18802f2c6aa59ce31be0d23 (diff)
downloadalembic-70115dc5d65e1f2e665d3b94cf7734184c3b96e2.tar.gz
enable extensions to use AutogenContext.run_name_filters
Adjusted the recently added :paramref:`.EnvironmentContext.configure.include_name` hook to accommodate for additional object types such as "views" that don't have a parent table, to support third party recipes and extensions. Pull request courtesy Oliver Rice. Fixes: #813 Closes: #814 Pull-request: https://github.com/sqlalchemy/alembic/pull/814 Pull-request-sha: 45dbc9c3baebd02c44cdcafc7ac73f00e87d8a86 Change-Id: I75f22b745bd847638b9fdff9c19c1f0091a6b470
Diffstat (limited to 'tests')
-rw-r--r--tests/test_autogen_diffs.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test_autogen_diffs.py b/tests/test_autogen_diffs.py
index a2215af..02a750a 100644
--- a/tests/test_autogen_diffs.py
+++ b/tests/test_autogen_diffs.py
@@ -1188,6 +1188,60 @@ class AutogenerateCustomCompareTypeTest(AutogenTest, TestBase):
eq_(diffs[1][0][0], "modify_type")
+class IncludeFiltersAPITest(AutogenTest, TestBase):
+ @classmethod
+ def _get_db_schema(cls):
+ return MetaData()
+
+ @classmethod
+ def _get_model_schema(cls):
+ return MetaData()
+
+ def test_run_name_filters_supports_extension_types(self):
+ include_name = mock.Mock()
+
+ self._update_context(name_filters=include_name, include_schemas=True)
+
+ self.autogen_context.run_name_filters(
+ name="some_function",
+ type_="function",
+ parent_names={"schema_name": "public"},
+ )
+
+ eq_(
+ include_name.mock_calls,
+ [
+ mock.call(
+ "some_function", "function", {"schema_name": "public"}
+ )
+ ],
+ )
+
+ def test_run_object_filters_supports_extension_types(self):
+ include_object = mock.Mock()
+
+ self._update_context(
+ object_filters=include_object, include_schemas=True
+ )
+
+ class ExtFunction(object):
+ pass
+
+ extfunc = ExtFunction()
+ self.autogen_context.run_object_filters(
+ object_=extfunc,
+ name="some_function",
+ type_="function",
+ reflected=False,
+ compare_to=None,
+ )
+
+ eq_(
+ include_object.mock_calls,
+ [mock.call(extfunc, "some_function", "function", False, None)],
+ )
+
+
class PKConstraintUpgradesIgnoresNullableTest(AutogenTest, TestBase):
__backend__ = True