import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene


class TestOgn(ogts.OmniGraphTestCase):

    async def test_data_access(self):
        from omni.graph.test.ogn.OgnBundleProducerDatabase import OgnBundleProducerDatabase
        (_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
            og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_test_BundleProducer", "omni.graph.test.BundleProducer")
        })
        database = OgnBundleProducerDatabase(test_node)
        self.assertTrue(test_node.is_valid())
        node_type_name = test_node.get_type_name()
        self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)

        def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
            test_type = "USD Load" if usd_test else "Database Access"
            return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"


        self.assertTrue(test_node.get_attribute_exists("outputs_bundle"))
        attribute = test_node.get_attribute("outputs_bundle")
        db_value = database.outputs.bundle
