I have an application specific complex data structure and a custom test plugin for comparing them with varying criteria. Now I want to use that test in some custom filter plugin(s). What’s the canonical python way to use custom tests from custom filters?
Maybe my question wasn’t clear. I have a project level custom test that lives in ./test_plugins/tablinx.py relative to the root of our project. The test itself is called mw_tab_sch_distinct, and it returns True if two compared dicts describe functionally different “schedules” (as per Tableau server definitions of schedules). “Functionally distinct” means we ignore fields like “name” which can be different without changing the timing of the schedule. Likewise we ignore the ordering of certain internal lists since a schedule definition containing [‘Monday’, ‘Wednesday’, ‘Friday’] and another containing [‘Wednesday’, ‘Friday’, ‘Monday’] are not distinct. Suffice to say, it’s nuanced.
I have another project level custom filter that lives in ./filter_plugins/tablinx.py, also relative to the project root. The filter itself is called mw_tab_sch_uniqcomb, and it accepts a list of Tableau “schedule” dicts, and returns two lists. The first list contains all the functionally distinct schedules from the input, while the second list contains zero or more lists each of which contains two or more functionally identical schedules from the input list.
All of this works, but only because the guts of the custom test plugin code is duplicated in the custom filter plugin. This is DIY-wrong beyond embarrassing. There must be a way to reference and use the custom tests contained within ./test_plugins/tablinx.py from the custom filters sitting in ./filter_plugins/tablinx.py.
Any suggestions would be greatly appreciated.