"""Testing the stability of the API in this module"""
import omni.graph.tools as ogt
import omni.graph.tools.ogn as ogn
import omni.kit
from omni.graph.tools.tests.internal_utils import _check_module_api_consistency, _check_public_api_contents


# ======================================================================
class _TestOmniGraphToolsApi(omni.kit.test.AsyncTestCase):
    _UNPUBLISHED = ["bindings", "ogn", "tests", "node_generator"]

    async def test_api(self):
        _check_module_api_consistency(  # noqa: PLW0212
            ogt.tests,
            ["internal_utils", "deprecated_import"],
            is_test_module=True,
        )
        _check_module_api_consistency(ogn, ogn._HIDDEN)  # noqa: PLW0212
        # Since the ogt module also contains all of the previously exposed objects for backward compatibility, they
        # have to be added to the list of unpublished elements here as they, rightly, do not appear in __all__.
        # There is also the rogue published deprecated function that is being used downstream and so has to be
        # omitted from the "in ogn but not ogt" list.
        all_unpublished = self._UNPUBLISHED + [
            module_object
            for module_object in dir(ogn)
            if not module_object.startswith("_") and module_object not in ["supported_attribute_type_names"]
        ]
        _check_module_api_consistency(ogt, all_unpublished)  # noqa: PLW0212

    async def test_api_features(self):
        """Test that the known public API features continue to exist"""
        _check_public_api_contents(
            ogt,
            [  # noqa: PLW0212
                "dbg_gc",
                "dbg_ui",
                "dbg",
                "deprecated_constant_object",
                "deprecated_function",
                "DeprecatedClass",
                "DeprecatedDictConstant",
                "DeprecatedImport",
                "DeprecatedStringConstant",
                "DeprecateMessage",
                "DeprecationLevel",
                "destroy_property",
                "function_trace",
                "import_tests_in_directory",
                "IndentedOutput",
                "RenamedClass",
                "shorten_string_lines_to",
                "supported_attribute_type_names",
            ],
            self._UNPUBLISHED,
            only_expected_allowed=False,
        )
