"""Test the utility functions found in ogn_types.py.
These are almost unit tests, they just require the Kit environment to work due to the imports.
"""
import omni.graph.tools.ogn as ogn
import omni.kit.test

# This test uses some imports that aren't exposed as part of the public interface
from omni.graph.tools._1_11 import OGN_TO_SDF_BASE_NAME, SDF_BASE_NAME_TO_OGN, SDF_TO_OGN


class TestOmniGraphTypeSupport(omni.kit.test.AsyncTestCase):
    """Tests the basic operation of the utilities found in ogn_types.py"""

    async def test_ogn_to_sdf_conversion(self):
        """Test consistency when converting to and from OGN and SDF type definitions"""
        self.assertEqual(len(OGN_TO_SDF_BASE_NAME), len(SDF_BASE_NAME_TO_OGN))
        self.assertEqual(len(SDF_BASE_NAME_TO_OGN) * 2, len(SDF_TO_OGN))

        for sdf_type, ogn_type_name in SDF_TO_OGN.items():
            ogn_converted_name = ogn.sdf_to_ogn(sdf_type)
            self.assertEqual(ogn_type_name, ogn_converted_name, f"Converting SDF {sdf_type} to OGN type name")
            sdf_converted_type = ogn.ogn_to_sdf(ogn_type_name)
            self.assertEqual(sdf_type, sdf_converted_type, f"Converting OGN type name {ogn_type_name} to SDF")
