file_path
stringlengths 21
224
| content
stringlengths 0
80.8M
|
---|---|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantInt.py | import os
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.nodes.ogn.OgnConstantIntDatabase import OgnConstantIntDatabase
test_file_name = "OgnConstantIntTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantInt")
database = OgnConstantIntDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNormalize.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:vector', {'type': 'float[3]', 'value': [1.0, 1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [0.57735027, 0.57735027, 0.57735027]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3]', 'value': [1.0, 0.0, 0.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [1.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3]', 'value': [5.0, 0.0, 0.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [1.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3]', 'value': [-1.0, 2.0, -3.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [-0.26726124, 0.53452248, -0.80178373]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'double[3]', 'value': [1.0, 1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'double[3]', 'value': [0.57735027, 0.57735027, 0.57735027]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'half[3]', 'value': [1.0, 1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'half[3]', 'value': [0.57714844, 0.57714844, 0.57714844]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3][]', 'value': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3][]', 'value': [[0.26726124, 0.5345225, 0.8017837], [0.45584232, 0.5698029, 0.6837635]]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'half[3][]', 'value': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}, False],
],
'outputs': [
['outputs:result', {'type': 'half[3][]', 'value': [[0.26733398, 0.53466797, 0.8017578], [0.45581055, 0.5698242, 0.68359375]]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[2]', 'value': [1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [0.70710677, 0.70710677]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[4]', 'value': [1.0, 2.0, 3.0, 4.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[4]', 'value': [0.18257418, 0.36514837, 0.5477226, 0.73029673]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Normalize", "omni.graph.nodes.Normalize", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Normalize User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Normalize","omni.graph.nodes.Normalize", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Normalize User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Normalize", "omni.graph.nodes.Normalize", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Normalize User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNormalizeDatabase import OgnNormalizeDatabase
test_file_name = "OgnNormalizeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Normalize")
database = OgnNormalizeDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayRemoveValue.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': []}, False],
['inputs:removeAll', False, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', False, False],
['outputs:array', {'type': 'int[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42, 41]}, False],
['inputs:removeAll', False, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[]', 'value': [42, 41]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42, 43, 41]}, False],
['inputs:removeAll', True, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[]', 'value': [42, 43]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 41, 41, 41]}, False],
['inputs:removeAll', True, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOO'}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', False, False],
['outputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOOD'}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'token[]', 'value': ['BARFOOD', 'BAZ']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'int64', 'value': 41}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int64[]', 'value': [42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uchar[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uchar', 'value': 41}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'uchar[]', 'value': [42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint', 'value': 42}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'uint[]', 'value': [41]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint64', 'value': 42}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'uint64[]', 'value': [41]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:value', {'type': 'bool', 'value': False}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'bool[]', 'value': [True]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:value', {'type': 'half[2]', 'value': [1, 2]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'half[2][]', 'value': [[3, 4]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[1, 2], [3, 4], [5, 6]]}, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'double[2][]', 'value': [[3, 4], [5, 6]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[1, 2], [3, 4], [5, 6], [1, 2]]}, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
['inputs:removeAll', True, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'double[2][]', 'value': [[3, 4], [5, 6]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.0], [3, 4, 5]]}, False],
['inputs:value', {'type': 'double[3]', 'value': [3, 4, 5]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.0]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.0], [3, 4, 5]]}, False],
['inputs:value', {'type': 'double[3]', 'value': [3.1, 4, 5]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', False, False],
['outputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.0], [3, 4, 5]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[4][]', 'value': [[1, 2, 3, 4], [3, 4, 5, 6]]}, False],
['inputs:value', {'type': 'int[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[4][]', 'value': [[3, 4, 5, 6]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayRemoveValue", "omni.graph.nodes.ArrayRemoveValue", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveValue User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayRemoveValue","omni.graph.nodes.ArrayRemoveValue", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveValue User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayRemoveValue", "omni.graph.nodes.ArrayRemoveValue", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayRemoveValue User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayRemoveValueDatabase import OgnArrayRemoveValueDatabase
test_file_name = "OgnArrayRemoveValueTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayRemoveValue")
database = OgnArrayRemoveValueDatabase(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("inputs:removeAll"))
attribute = test_node.get_attribute("inputs:removeAll")
db_value = database.inputs.removeAll
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:found"))
attribute = test_node.get_attribute("outputs:found")
db_value = database.outputs.found
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantHalf2.py | import os
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.nodes.ogn.OgnConstantHalf2Database import OgnConstantHalf2Database
test_file_name = "OgnConstantHalf2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantHalf2")
database = OgnConstantHalf2Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble3.py | import os
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.nodes.ogn.OgnConstantDouble3Database import OgnConstantDouble3Database
test_file_name = "OgnConstantDouble3Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantDouble3")
database = OgnConstantDouble3Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomUnitVector.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', [0.99799526, 0.02564502, -0.05785976], False],
['outputs:execOut', 1, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomUnitVector", "omni.graph.nodes.RandomUnitVector", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitVector User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomUnitVector","omni.graph.nodes.RandomUnitVector", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitVector User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RandomUnitVector", "omni.graph.nodes.RandomUnitVector", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RandomUnitVector User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomUnitVectorDatabase import OgnRandomUnitVectorDatabase
test_file_name = "OgnRandomUnitVectorTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RandomUnitVector")
database = OgnRandomUnitVectorDatabase(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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:isNoise"))
attribute = test_node.get_attribute("inputs:isNoise")
db_value = database.inputs.isNoise
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useSeed"))
attribute = test_node.get_attribute("inputs:useSeed")
db_value = database.inputs.useSeed
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("outputs:random"))
attribute = test_node.get_attribute("outputs:random")
db_value = database.outputs.random
self.assertTrue(test_node.get_attribute_exists("state:gen"))
attribute = test_node.get_attribute("state:gen")
db_value = database.state.gen
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnStartsWith.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:value', "", False],
['inputs:prefix', "", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "a", False],
['inputs:prefix', "", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "", False],
['inputs:prefix', "a", False],
],
'outputs': [
['outputs:isPrefix', False, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:prefix', "a", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:prefix', "aa", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:prefix', "aaa", False],
],
'outputs': [
['outputs:isPrefix', False, False],
],
},
{
'inputs': [
['inputs:value', "aaa", False],
['inputs:prefix', "aa", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_StartsWith", "omni.graph.nodes.StartsWith", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.StartsWith User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_StartsWith","omni.graph.nodes.StartsWith", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.StartsWith User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_StartsWith", "omni.graph.nodes.StartsWith", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.StartsWith User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnStartsWithDatabase import OgnStartsWithDatabase
test_file_name = "OgnStartsWithTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_StartsWith")
database = OgnStartsWithDatabase(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("inputs:prefix"))
attribute = test_node.get_attribute("inputs:prefix")
db_value = database.inputs.prefix
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:isPrefix"))
attribute = test_node.get_attribute("outputs:isPrefix")
db_value = database.outputs.isPrefix
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnDotProduct.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'double[2]', 'value': [1, 2]}, False],
['inputs:b', {'type': 'double[2]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 11}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'double[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 38}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [10.2, 3.5, 7, 0]}, False],
['inputs:b', {'type': 'double[4]', 'value': [5, 6.1, 4.2, 5]}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 101.75}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4][]', 'value': [[3, 6.5, 2, 0], [4, 3.6, 2, 0]]}, False],
['inputs:b', {'type': 'double[4][]', 'value': [[5, 6.1, -2.1, 5], [3, 5, -2, 7]]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[]', 'value': [50.449999999999996, 26.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'half[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'half', 'value': 38}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_DotProduct", "omni.graph.nodes.DotProduct", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.DotProduct User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_DotProduct","omni.graph.nodes.DotProduct", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.DotProduct User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_DotProduct", "omni.graph.nodes.DotProduct", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.DotProduct User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnDotProductDatabase import OgnDotProductDatabase
test_file_name = "OgnDotProductTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_DotProduct")
database = OgnDotProductDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPi.py | import os
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.nodes.ogn.OgnConstantPiDatabase import OgnConstantPiDatabase
test_file_name = "OgnConstantPiTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantPi")
database = OgnConstantPiDatabase(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("inputs:factor"))
attribute = test_node.get_attribute("inputs:factor")
db_value = database.inputs.factor
expected_value = 1
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBooleanExpr.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', True, False],
['inputs:b', True, False],
['inputs:operator', "XOR", False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:a', True, False],
['inputs:b', True, False],
['inputs:operator', "XNOR", False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:a', True, False],
['inputs:b', False, False],
['inputs:operator', "OR", False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:a', True, False],
['inputs:b', False, False],
['inputs:operator', "AND", False],
],
'outputs': [
['outputs:result', False, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanExpr", "omni.graph.nodes.BooleanExpr", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanExpr User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanExpr","omni.graph.nodes.BooleanExpr", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanExpr User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBooleanExprDatabase import OgnBooleanExprDatabase
test_file_name = "OgnBooleanExprTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BooleanExpr")
database = OgnBooleanExprDatabase(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("inputs:a"))
attribute = test_node.get_attribute("inputs:a")
db_value = database.inputs.a
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:b"))
attribute = test_node.get_attribute("inputs:b")
db_value = database.inputs.b
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:operator"))
attribute = test_node.get_attribute("inputs:operator")
db_value = database.inputs.operator
expected_value = "AND"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:result"))
attribute = test_node.get_attribute("outputs:result")
db_value = database.outputs.result
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRotateToTarget.py | import os
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.nodes.ogn.OgnRotateToTargetDatabase import OgnRotateToTargetDatabase
test_file_name = "OgnRotateToTargetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RotateToTarget")
database = OgnRotateToTargetDatabase(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), 2)
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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:stop"))
attribute = test_node.get_attribute("inputs:stop")
db_value = database.inputs.stop
self.assertTrue(test_node.get_attribute_exists("inputs:useSourcePath"))
attribute = test_node.get_attribute("inputs:useSourcePath")
db_value = database.inputs.useSourcePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useTargetPath"))
attribute = test_node.get_attribute("inputs:useTargetPath")
db_value = database.inputs.useTargetPath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayRemoveIndex.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:index', 0, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [True, False]}, False],
['inputs:index', 0, False],
],
'outputs': [
['outputs:array', {'type': 'bool[]', 'value': [False]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:array', {'type': 'half[2][]', 'value': [[1, 2]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['41', '42']}, False],
['inputs:index', -2, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['42']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42, 43, 41]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [41, 43, 41]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayRemoveIndex", "omni.graph.nodes.ArrayRemoveIndex", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveIndex User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayRemoveIndex","omni.graph.nodes.ArrayRemoveIndex", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveIndex User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayRemoveIndex", "omni.graph.nodes.ArrayRemoveIndex", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayRemoveIndex User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayRemoveIndexDatabase import OgnArrayRemoveIndexDatabase
test_file_name = "OgnArrayRemoveIndexTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayRemoveIndex")
database = OgnArrayRemoveIndexDatabase(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("inputs:index"))
attribute = test_node.get_attribute("inputs:index")
db_value = database.inputs.index
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetParentPath.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': ''}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World/foo'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/World'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World/foo/bar'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/World/foo'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World/foo/bar.attrib'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/World/foo/bar'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token[]', 'value': ['/World1/foo', '/World2/bar']}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token[]', 'value': ['/World1', '/World2']}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetParentPath", "omni.graph.nodes.GetParentPath", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetParentPath User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetParentPath","omni.graph.nodes.GetParentPath", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetParentPath User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_GetParentPath", "omni.graph.nodes.GetParentPath", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.GetParentPath User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetParentPathDatabase import OgnGetParentPathDatabase
test_file_name = "OgnGetParentPathTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetParentPath")
database = OgnGetParentPathDatabase(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("state:path"))
attribute = test_node.get_attribute("state:path")
db_value = database.state.path
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSubtract.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 1.0}, False],
['inputs:b', {'type': 'double', 'value': 0.5}, False],
],
'outputs': [
['outputs:difference', {'type': 'double', 'value': 0.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 1.0}, False],
['inputs:b', {'type': 'float', 'value': 0.5}, False],
],
'outputs': [
['outputs:difference', {'type': 'float', 'value': 0.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 1.0}, False],
['inputs:b', {'type': 'half', 'value': 0.5}, False],
],
'outputs': [
['outputs:difference', {'type': 'half', 'value': 0.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 10}, False],
['inputs:b', {'type': 'int', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'int', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 10}, False],
['inputs:b', {'type': 'int64', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 10}, False],
['inputs:b', {'type': 'uchar', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'uchar', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint', 'value': 10}, False],
['inputs:b', {'type': 'uint', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'uint', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 10}, False],
['inputs:b', {'type': 'uint64', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'uint64', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'float[2]', 'value': [0.5, 1.0]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[2]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[3]', 'value': [1.0, 2.0, 3.0]}, False],
['inputs:b', {'type': 'float[3]', 'value': [0.5, 1.0, 1.5]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[3]', 'value': [0.5, 1.0, 1.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[4]', 'value': [1.0, 2.0, 3.0, 4.0]}, False],
['inputs:b', {'type': 'float[4]', 'value': [0.5, 1.0, 1.5, 2.0]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[4]', 'value': [0.5, 1.0, 1.5, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2]', 'value': [2.0, 3.0]}, False],
['inputs:b', {'type': 'float', 'value': 1.0}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 1.0}, False],
['inputs:b', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[2]', 'value': [0.0, -1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [2.0, 3.0]}, False],
['inputs:b', {'type': 'float', 'value': 1.0}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 1.0}, False],
['inputs:b', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[]', 'value': [0.0, -1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10, 20]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5, 10]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5, 10]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10, 20, 30]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5, 10, 15]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5, 10, 15]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10, 20, 30, 40]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5, 10, 15, 20]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5, 10, 15, 20]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[3][]', 'value': [[10, 20, 30], [40, 50, 60]]}, False],
['inputs:b', {'type': 'int[3]', 'value': [5, 10, 15]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[3][]', 'value': [[5, 10, 15], [35, 40, 45]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[3]', 'value': [5, 10, 15]}, False],
['inputs:b', {'type': 'int[3][]', 'value': [[10, 20, 30], [40, 50, 60]]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[3][]', 'value': [[-5, -10, -15], [-35, -40, -45]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[2][]', 'value': [[10, 20], [30, 40], [50, 60]]}, False],
['inputs:b', {'type': 'int[2]', 'value': [5, 10]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[2][]', 'value': [[5, 10], [25, 30], [45, 50]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[2]', 'value': [5, 10]}, False],
['inputs:b', {'type': 'int[2][]', 'value': [[10, 20], [30, 40], [50, 60]]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[2][]', 'value': [[-5, -10], [-25, -30], [-45, -50]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Subtract", "omni.graph.nodes.Subtract", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Subtract User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Subtract","omni.graph.nodes.Subtract", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Subtract User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Subtract", "omni.graph.nodes.Subtract", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Subtract User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSubtractDatabase import OgnSubtractDatabase
test_file_name = "OgnSubtractTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Subtract")
database = OgnSubtractDatabase(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), 2)
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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBreakVector3.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:tuple', {'type': 'float[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
['outputs:z', {'type': 'float', 'value': 0.0}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'int[3]', 'value': [42, -42, 5]}, False],
],
'outputs': [
['outputs:x', {'type': 'int', 'value': 42}, False],
['outputs:y', {'type': 'int', 'value': -42}, False],
['outputs:z', {'type': 'int', 'value': 5}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'colorf[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
['outputs:z', {'type': 'float', 'value': 0.0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector3", "omni.graph.nodes.BreakVector3", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector3 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector3","omni.graph.nodes.BreakVector3", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector3 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BreakVector3", "omni.graph.nodes.BreakVector3", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BreakVector3 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBreakVector3Database import OgnBreakVector3Database
test_file_name = "OgnBreakVector3Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BreakVector3")
database = OgnBreakVector3Database(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCompare.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 1.0}, False],
['inputs:operation', ">", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 1.0}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:b', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'float[]', 'value': [1.0, 2.01]}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [True, False]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[]', 'value': [2.0, 3.0]}, False],
['inputs:b', {'type': 'double[]', 'value': [2.0, 3.1]}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [True, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3][]', 'value': [[2.0, 3.0, 1.0], [1.0, 2.0, 5.0]]}, False],
['inputs:b', {'type': 'double[3][]', 'value': [[2.0, 1.0, 4.0], [2.0, 2.0, 2.0]]}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': ''}, False],
['inputs:b', {'type': 'token', 'value': ''}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': 'abc'}, False],
['inputs:b', {'type': 'token', 'value': 'abc'}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': 'abc'}, False],
['inputs:b', {'type': 'token', 'value': 'd'}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': 'abc'}, False],
['inputs:b', {'type': 'token', 'value': ''}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': ''}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'abc'}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'd'}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': ''}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', "<", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'ad'}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', ">", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'abc'}, False],
['inputs:operation', ">=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar[]', 'value': []}, False],
['inputs:b', {'type': 'uchar[]', 'value': []}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'uchar[]', 'value': [97, 98, 99]}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, False, False]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar[]', 'value': [97, 98, 99]}, False],
['inputs:b', {'type': 'uchar', 'value': 98}, False],
['inputs:operation', ">", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, False, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 98}, False],
['inputs:b', {'type': 'string', 'value': 'abc'}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, True, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token[]', 'value': ['abcd', 'a', 'foo']}, False],
['inputs:b', {'type': 'token[]', 'value': ['abc', 'a', 'food']}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [True, False, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': ''}, False],
['inputs:b', {'type': 'token[]', 'value': ['abc', 'a', '']}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, False, True]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Compare", "omni.graph.nodes.Compare", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Compare User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Compare","omni.graph.nodes.Compare", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Compare User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Compare", "omni.graph.nodes.Compare", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Compare User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCompareDatabase import OgnCompareDatabase
test_file_name = "OgnCompareTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Compare")
database = OgnCompareDatabase(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("inputs:operation"))
attribute = test_node.get_attribute("inputs:operation")
db_value = database.inputs.operation
expected_value = ">"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeTransformLookAt.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:eye', [1, 0, 0], False],
['inputs:center', [0, 0, 1], False],
['inputs:up', [0, 1, 0], False],
],
'outputs': [
['outputs:transform', [0.70710678, 0, -0.70710678, 0, 0, 1, 0, 0, 0.70710678, 0, 0.70710678, 0, -0.70710678, 0, -0.70710678, 1], False],
],
},
{
'inputs': [
['inputs:eye', [1, 0, 0], False],
['inputs:center', [0, 0, 0], False],
['inputs:up', [0, 1, 0], False],
],
'outputs': [
['outputs:transform', [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeTransformLookAt", "omni.graph.nodes.MakeTransformLookAt", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransformLookAt User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeTransformLookAt","omni.graph.nodes.MakeTransformLookAt", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransformLookAt User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeTransformLookAt", "omni.graph.nodes.MakeTransformLookAt", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeTransformLookAt User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeTransformLookAtDatabase import OgnMakeTransformLookAtDatabase
test_file_name = "OgnMakeTransformLookAtTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeTransformLookAt")
database = OgnMakeTransformLookAtDatabase(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("inputs:center"))
attribute = test_node.get_attribute("inputs:center")
db_value = database.inputs.center
expected_value = [0, 0, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:eye"))
attribute = test_node.get_attribute("inputs:eye")
db_value = database.inputs.eye
expected_value = [1, 0, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:up"))
attribute = test_node.get_attribute("inputs:up")
db_value = database.inputs.up
expected_value = [0, 1, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:transform"))
attribute = test_node.get_attribute("outputs:transform")
db_value = database.outputs.transform
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnFMod.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 4.0}, False],
['inputs:b', {'type': 'float', 'value': 3.625}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 0.375}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [4.0, 7.625]}, False],
['inputs:b', {'type': 'float', 'value': 3.625}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.375, 0.375]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': -4.0}, False],
['inputs:b', {'type': 'half', 'value': 3.625}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': -0.375}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_FMod", "omni.graph.nodes.FMod", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FMod User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_FMod","omni.graph.nodes.FMod", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FMod User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnFModDatabase import OgnFModDatabase
test_file_name = "OgnFModTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_FMod")
database = OgnFModDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnHasVariantSet.py | import os
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.nodes.ogn.OgnHasVariantSetDatabase import OgnHasVariantSetDatabase
test_file_name = "OgnHasVariantSetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_HasVariantSet")
database = OgnHasVariantSetDatabase(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), 2)
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("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:variantSetName"))
attribute = test_node.get_attribute("inputs:variantSetName")
db_value = database.inputs.variantSetName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:exists"))
attribute = test_node.get_attribute("outputs:exists")
db_value = database.outputs.exists
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble4.py | import os
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.nodes.ogn.OgnConstantDouble4Database import OgnConstantDouble4Database
test_file_name = "OgnConstantDouble4Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantDouble4")
database = OgnConstantDouble4Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSourceIndices.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:sourceStartsInTarget', [1, 2, 3, 5, 6, 6], False],
],
'outputs': [
['outputs:sourceIndices', [0, 0, 1, 2, 2, 3], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SourceIndices", "omni.graph.nodes.SourceIndices", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SourceIndices User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SourceIndices","omni.graph.nodes.SourceIndices", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SourceIndices User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SourceIndices", "omni.graph.nodes.SourceIndices", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SourceIndices User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSourceIndicesDatabase import OgnSourceIndicesDatabase
test_file_name = "OgnSourceIndicesTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SourceIndices")
database = OgnSourceIndicesDatabase(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("inputs:sourceStartsInTarget"))
attribute = test_node.get_attribute("inputs:sourceStartsInTarget")
db_value = database.inputs.sourceStartsInTarget
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:sourceIndices"))
attribute = test_node.get_attribute("outputs:sourceIndices")
db_value = database.outputs.sourceIndices
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantUInt64.py | import os
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.nodes.ogn.OgnConstantUInt64Database import OgnConstantUInt64Database
test_file_name = "OgnConstantUInt64Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantUInt64")
database = OgnConstantUInt64Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToDouble.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'float[]', 'value': []}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.1}, False],
],
'outputs': [
['outputs:converted', {'type': 'double', 'value': 2.1}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:converted', {'type': 'double', 'value': 42.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[]', 'value': [1.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[2]', 'value': [2.1, 2.1]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[2]', 'value': [2.1, 2.1]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3]', 'value': [2, 3, 4]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[3]', 'value': [2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3][]', 'value': [[2, 3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[3][]', 'value': [[2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2][]', 'value': [[1, 2], [3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToDouble", "omni.graph.nodes.ToDouble", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDouble User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToDouble","omni.graph.nodes.ToDouble", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDouble User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToDouble", "omni.graph.nodes.ToDouble", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToDouble User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToDoubleDatabase import OgnToDoubleDatabase
test_file_name = "OgnToDoubleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToDouble")
database = OgnToDoubleDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNoOp.py | import os
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.nodes.ogn.OgnNoOpDatabase import OgnNoOpDatabase
test_file_name = "OgnNoOpTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Noop")
database = OgnNoOpDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrim.py | import os
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.nodes.ogn.OgnReadPrimDatabase import OgnReadPrimDatabase
test_file_name = "OgnReadPrimTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrim")
database = OgnReadPrimDatabase(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), 9)
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("inputs:attrNamesToImport"))
attribute = test_node.get_attribute("inputs:attrNamesToImport")
db_value = database.inputs.attrNamesToImport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:computeBoundingBox"))
attribute = test_node.get_attribute("inputs:computeBoundingBox")
db_value = database.inputs.computeBoundingBox
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_primBundle"))
attribute = test_node.get_attribute("outputs_primBundle")
db_value = database.outputs.primBundle
self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport"))
attribute = test_node.get_attribute("state:attrNamesToImport")
db_value = database.state.attrNamesToImport
self.assertTrue(test_node.get_attribute_exists("state:computeBoundingBox"))
attribute = test_node.get_attribute("state:computeBoundingBox")
db_value = database.state.computeBoundingBox
self.assertTrue(test_node.get_attribute_exists("state:primPath"))
attribute = test_node.get_attribute("state:primPath")
db_value = database.state.primPath
self.assertTrue(test_node.get_attribute_exists("state:primTypes"))
attribute = test_node.get_attribute("state:primTypes")
db_value = database.state.primTypes
self.assertTrue(test_node.get_attribute_exists("state:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnXor.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, False, True, True]}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True, False, True]}, False],
],
'outputs': [
['outputs:result', [False, True, True, False], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False],
],
'outputs': [
['outputs:result', [False, True], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:b', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', [False, True], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanXor", "omni.graph.nodes.BooleanXor", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanXor User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanXor","omni.graph.nodes.BooleanXor", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanXor User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BooleanXor", "omni.graph.nodes.BooleanXor", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BooleanXor User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnXorDatabase import OgnXorDatabase
test_file_name = "OgnXorTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BooleanXor")
database = OgnXorDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnFindPrims.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:namePrefix', "Xform", False],
],
'outputs': [
['outputs:primPaths', ["/Xform1", "/Xform2", "/XformTagged1"], False],
],
'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.FindPrims']], 'create_prims': [['Empty', {}], ['Xform1', {'_translate': ['pointd[3][]', [[1, 2, 3]]]}], ['Xform2', {'_translate': ['pointd[3][]', [[4, 5, 6]]]}], ['XformTagged1', {'foo': ['token', ''], '_translate': ['pointd[3][]', [[1, 2, 3]]]}], ['Tagged1', {'foo': ['token', '']}]]} },
{
'inputs': [
['inputs:namePrefix', "", False],
['inputs:requiredAttributes', "foo _translate", False],
],
'outputs': [
['outputs:primPaths', ["/XformTagged1"], False],
],
'setup': {} },
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_FindPrims", "omni.graph.nodes.FindPrims", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FindPrims User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_FindPrims","omni.graph.nodes.FindPrims", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FindPrims User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_FindPrims", "omni.graph.nodes.FindPrims", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.FindPrims User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnFindPrimsDatabase import OgnFindPrimsDatabase
test_file_name = "OgnFindPrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_FindPrims")
database = OgnFindPrimsDatabase(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), 2)
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("inputs:ignoreSystemPrims"))
attribute = test_node.get_attribute("inputs:ignoreSystemPrims")
db_value = database.inputs.ignoreSystemPrims
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:namePrefix"))
attribute = test_node.get_attribute("inputs:namePrefix")
db_value = database.inputs.namePrefix
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:recursive"))
attribute = test_node.get_attribute("inputs:recursive")
db_value = database.inputs.recursive
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:requiredAttributes"))
attribute = test_node.get_attribute("inputs:requiredAttributes")
db_value = database.inputs.requiredAttributes
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:requiredRelationship"))
attribute = test_node.get_attribute("inputs:requiredRelationship")
db_value = database.inputs.requiredRelationship
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:requiredRelationshipTarget"))
attribute = test_node.get_attribute("inputs:requiredRelationshipTarget")
db_value = database.inputs.requiredRelationshipTarget
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:requiredTarget"))
attribute = test_node.get_attribute("inputs:requiredTarget")
db_value = database.inputs.requiredTarget
self.assertTrue(test_node.get_attribute_exists("inputs:rootPrim"))
attribute = test_node.get_attribute("inputs:rootPrim")
db_value = database.inputs.rootPrim
self.assertTrue(test_node.get_attribute_exists("inputs:rootPrimPath"))
attribute = test_node.get_attribute("inputs:rootPrimPath")
db_value = database.inputs.rootPrimPath
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:type"))
attribute = test_node.get_attribute("inputs:type")
db_value = database.inputs.type
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:primPaths"))
attribute = test_node.get_attribute("outputs:primPaths")
db_value = database.outputs.primPaths
self.assertTrue(test_node.get_attribute_exists("outputs:prims"))
attribute = test_node.get_attribute("outputs:prims")
db_value = database.outputs.prims
self.assertTrue(test_node.get_attribute_exists("state:ignoreSystemPrims"))
attribute = test_node.get_attribute("state:ignoreSystemPrims")
db_value = database.state.ignoreSystemPrims
self.assertTrue(test_node.get_attribute_exists("state:inputType"))
attribute = test_node.get_attribute("state:inputType")
db_value = database.state.inputType
self.assertTrue(test_node.get_attribute_exists("state:namePrefix"))
attribute = test_node.get_attribute("state:namePrefix")
db_value = database.state.namePrefix
self.assertTrue(test_node.get_attribute_exists("state:pathPattern"))
attribute = test_node.get_attribute("state:pathPattern")
db_value = database.state.pathPattern
self.assertTrue(test_node.get_attribute_exists("state:recursive"))
attribute = test_node.get_attribute("state:recursive")
db_value = database.state.recursive
self.assertTrue(test_node.get_attribute_exists("state:requiredAttributes"))
attribute = test_node.get_attribute("state:requiredAttributes")
db_value = database.state.requiredAttributes
self.assertTrue(test_node.get_attribute_exists("state:requiredRelationship"))
attribute = test_node.get_attribute("state:requiredRelationship")
db_value = database.state.requiredRelationship
self.assertTrue(test_node.get_attribute_exists("state:requiredRelationshipTarget"))
attribute = test_node.get_attribute("state:requiredRelationshipTarget")
db_value = database.state.requiredRelationshipTarget
self.assertTrue(test_node.get_attribute_exists("state:requiredTarget"))
attribute = test_node.get_attribute("state:requiredTarget")
db_value = database.state.requiredTarget
self.assertTrue(test_node.get_attribute_exists("state:rootPrim"))
attribute = test_node.get_attribute("state:rootPrim")
db_value = database.state.rootPrim
self.assertTrue(test_node.get_attribute_exists("state:rootPrimPath"))
attribute = test_node.get_attribute("state:rootPrimPath")
db_value = database.state.rootPrimPath
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/__init__.py | """====== GENERATED BY omni.graph.tools - DO NOT EDIT ======"""
import omni.graph.tools._internal as ogi
ogi.import_tests_in_directory(__file__, __name__)
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGpuInteropCudaEntry.py | import os
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.nodes.ogn.OgnGpuInteropCudaEntryDatabase import OgnGpuInteropCudaEntryDatabase
test_file_name = "OgnGpuInteropCudaEntryTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GpuInteropCudaEntry")
database = OgnGpuInteropCudaEntryDatabase(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("inputs:sourceName"))
attribute = test_node.get_attribute("inputs:sourceName")
db_value = database.inputs.sourceName
expected_value = "ldrColor"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:bufferSize"))
attribute = test_node.get_attribute("outputs:bufferSize")
db_value = database.outputs.bufferSize
self.assertTrue(test_node.get_attribute_exists("outputs:cudaMipmappedArray"))
attribute = test_node.get_attribute("outputs:cudaMipmappedArray")
db_value = database.outputs.cudaMipmappedArray
self.assertTrue(test_node.get_attribute_exists("outputs:externalTimeOfSimFrame"))
attribute = test_node.get_attribute("outputs:externalTimeOfSimFrame")
db_value = database.outputs.externalTimeOfSimFrame
self.assertTrue(test_node.get_attribute_exists("outputs:format"))
attribute = test_node.get_attribute("outputs:format")
db_value = database.outputs.format
self.assertTrue(test_node.get_attribute_exists("outputs:frameId"))
attribute = test_node.get_attribute("outputs:frameId")
db_value = database.outputs.frameId
self.assertTrue(test_node.get_attribute_exists("outputs:height"))
attribute = test_node.get_attribute("outputs:height")
db_value = database.outputs.height
self.assertTrue(test_node.get_attribute_exists("outputs:hydraTime"))
attribute = test_node.get_attribute("outputs:hydraTime")
db_value = database.outputs.hydraTime
self.assertTrue(test_node.get_attribute_exists("outputs:isBuffer"))
attribute = test_node.get_attribute("outputs:isBuffer")
db_value = database.outputs.isBuffer
self.assertTrue(test_node.get_attribute_exists("outputs:mipCount"))
attribute = test_node.get_attribute("outputs:mipCount")
db_value = database.outputs.mipCount
self.assertTrue(test_node.get_attribute_exists("outputs:simTime"))
attribute = test_node.get_attribute("outputs:simTime")
db_value = database.outputs.simTime
self.assertTrue(test_node.get_attribute_exists("outputs:stream"))
attribute = test_node.get_attribute("outputs:stream")
db_value = database.outputs.stream
self.assertTrue(test_node.get_attribute_exists("outputs:width"))
attribute = test_node.get_attribute("outputs:width")
db_value = database.outputs.width
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPath.py | import os
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.nodes.ogn.OgnConstantPathDatabase import OgnConstantPathDatabase
test_file_name = "OgnConstantPathTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantPath")
database = OgnConstantPathDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIncrement.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
['inputs:increment', 0.5, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [1.5, 2.5]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int64', 'value': 10}, False],
['inputs:increment', 1.2, False],
],
'outputs': [
['outputs:result', {'type': 'int64', 'value': 11}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:increment', 5.4, False],
],
'outputs': [
['outputs:result', {'type': 'double[2][]', 'value': [[15.4, 10.4], [6.4, 6.4]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:increment', 5, False],
],
'outputs': [
['outputs:result', {'type': 'double[2][]', 'value': [[15, 10], [6, 6]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.22045e-16}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.0000000000000002}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Increment", "omni.graph.nodes.Increment", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Increment User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Increment","omni.graph.nodes.Increment", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Increment User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Increment", "omni.graph.nodes.Increment", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Increment User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnIncrementDatabase import OgnIncrementDatabase
test_file_name = "OgnIncrementTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Increment")
database = OgnIncrementDatabase(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("inputs:increment"))
attribute = test_node.get_attribute("inputs:increment")
db_value = database.inputs.increment
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCurveTubeST.py | import os
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.nodes.ogn.OgnCurveTubeSTDatabase import OgnCurveTubeSTDatabase
test_file_name = "OgnCurveTubeSTTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CurveTubeST")
database = OgnCurveTubeSTDatabase(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("inputs:cols"))
attribute = test_node.get_attribute("inputs:cols")
db_value = database.inputs.cols
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexCounts"))
attribute = test_node.get_attribute("inputs:curveVertexCounts")
db_value = database.inputs.curveVertexCounts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexStarts"))
attribute = test_node.get_attribute("inputs:curveVertexStarts")
db_value = database.inputs.curveVertexStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:scaleTLikeS"))
attribute = test_node.get_attribute("inputs:scaleTLikeS")
db_value = database.inputs.scaleTLikeS
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:t"))
attribute = test_node.get_attribute("inputs:t")
db_value = database.inputs.t
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:tubeQuadStarts"))
attribute = test_node.get_attribute("inputs:tubeQuadStarts")
db_value = database.inputs.tubeQuadStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:tubeSTStarts"))
attribute = test_node.get_attribute("inputs:tubeSTStarts")
db_value = database.inputs.tubeSTStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:width"))
attribute = test_node.get_attribute("inputs:width")
db_value = database.inputs.width
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:primvars:st"))
attribute = test_node.get_attribute("outputs:primvars:st")
db_value = database.outputs.primvars_st
self.assertTrue(test_node.get_attribute_exists("outputs:primvars:st:indices"))
attribute = test_node.get_attribute("outputs:primvars:st:indices")
db_value = database.outputs.primvars_st_indices
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnExtractAttr.py | import os
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.nodes.ogn.OgnExtractAttrDatabase import OgnExtractAttrDatabase
test_file_name = "OgnExtractAttrTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ExtractAttribute")
database = OgnExtractAttrDatabase(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("inputs:attrName"))
attribute = test_node.get_attribute("inputs:attrName")
db_value = database.inputs.attrName
expected_value = "points"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:data"))
attribute = test_node.get_attribute("inputs:data")
db_value = database.inputs.data
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnEventUpdateTick.py | import os
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.nodes.ogn.OgnEventUpdateTickDatabase import OgnEventUpdateTickDatabase
test_file_name = "OgnEventUpdateTickTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_UpdateTickEvent")
database = OgnEventUpdateTickDatabase(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:event"))
attribute = test_node.get_attribute("outputs:event")
db_value = database.outputs.event
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomGaussian.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'float', 'value': 123.0}, False],
['inputs:stdev', {'type': 'float', 'value': 0.0}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float', 'value': 123.0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'double[]', 'value': [-100, 100]}, False],
['inputs:stdev', {'type': 'double', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'double[]', 'value': [-98.27423617, 100.04434614]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'half', 'value': 0}, False],
['inputs:stdev', {'type': 'half[2]', 'value': [1, 2]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'half[2]', 'value': [1.7255859, 0.08868408]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'float[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:stdev', {'type': 'float', 'value': 0}, False],
['inputs:useLog', True, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[2][]', 'value': [[1, 2], [3, 4]]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'float', 'value': 100}, False],
['inputs:stdev', {'type': 'float[]', 'value': [1, 1, 1, 1, 1]}, False],
['inputs:useLog', True, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[]', 'value': [101.735756, 100.03935, 99.89501, 100.42319, 99.54652]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 9302349107990861236, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'double', 'value': 0.6957887336760361}, False],
['outputs:execOut', 1, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomGaussian", "omni.graph.nodes.RandomGaussian", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomGaussian User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomGaussian","omni.graph.nodes.RandomGaussian", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomGaussian User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RandomGaussian", "omni.graph.nodes.RandomGaussian", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RandomGaussian User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomGaussianDatabase import OgnRandomGaussianDatabase
test_file_name = "OgnRandomGaussianTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RandomGaussian")
database = OgnRandomGaussianDatabase(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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:isNoise"))
attribute = test_node.get_attribute("inputs:isNoise")
db_value = database.inputs.isNoise
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useLog"))
attribute = test_node.get_attribute("inputs:useLog")
db_value = database.inputs.useLog
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useSeed"))
attribute = test_node.get_attribute("inputs:useSeed")
db_value = database.inputs.useSeed
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("state:gen"))
attribute = test_node.get_attribute("state:gen")
db_value = database.state.gen
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineGet.py | import os
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.nodes.ogn.OgnTimelineGetDatabase import OgnTimelineGetDatabase
test_file_name = "OgnTimelineGetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetTimeline")
database = OgnTimelineGetDatabase(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:endFrame"))
attribute = test_node.get_attribute("outputs:endFrame")
db_value = database.outputs.endFrame
self.assertTrue(test_node.get_attribute_exists("outputs:endTime"))
attribute = test_node.get_attribute("outputs:endTime")
db_value = database.outputs.endTime
self.assertTrue(test_node.get_attribute_exists("outputs:frame"))
attribute = test_node.get_attribute("outputs:frame")
db_value = database.outputs.frame
self.assertTrue(test_node.get_attribute_exists("outputs:framesPerSecond"))
attribute = test_node.get_attribute("outputs:framesPerSecond")
db_value = database.outputs.framesPerSecond
self.assertTrue(test_node.get_attribute_exists("outputs:isLooping"))
attribute = test_node.get_attribute("outputs:isLooping")
db_value = database.outputs.isLooping
self.assertTrue(test_node.get_attribute_exists("outputs:isPlaying"))
attribute = test_node.get_attribute("outputs:isPlaying")
db_value = database.outputs.isPlaying
self.assertTrue(test_node.get_attribute_exists("outputs:startFrame"))
attribute = test_node.get_attribute("outputs:startFrame")
db_value = database.outputs.startFrame
self.assertTrue(test_node.get_attribute_exists("outputs:startTime"))
attribute = test_node.get_attribute("outputs:startTime")
db_value = database.outputs.startTime
self.assertTrue(test_node.get_attribute_exists("outputs:time"))
attribute = test_node.get_attribute("outputs:time")
db_value = database.outputs.time
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIsPrimSelected.py | import os
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.nodes.ogn.OgnIsPrimSelectedDatabase import OgnIsPrimSelectedDatabase
test_file_name = "OgnIsPrimSelectedTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_IsPrimSelected")
database = OgnIsPrimSelectedDatabase(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("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:primPath"))
attribute = test_node.get_attribute("inputs:primPath")
db_value = database.inputs.primPath
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:isSelected"))
attribute = test_node.get_attribute("outputs:isSelected")
db_value = database.outputs.isSelected
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantBool.py | import os
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.nodes.ogn.OgnConstantBoolDatabase import OgnConstantBoolDatabase
test_file_name = "OgnConstantBoolTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantBool")
database = OgnConstantBoolDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBlendVariants.py | import os
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.nodes.ogn.OgnBlendVariantsDatabase import OgnBlendVariantsDatabase
test_file_name = "OgnBlendVariantsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BlendVariants")
database = OgnBlendVariantsDatabase(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("inputs:blend"))
attribute = test_node.get_attribute("inputs:blend")
db_value = database.inputs.blend
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:setVariant"))
attribute = test_node.get_attribute("inputs:setVariant")
db_value = database.inputs.setVariant
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantNameA"))
attribute = test_node.get_attribute("inputs:variantNameA")
db_value = database.inputs.variantNameA
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantNameB"))
attribute = test_node.get_attribute("inputs:variantNameB")
db_value = database.inputs.variantNameB
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantSetName"))
attribute = test_node.get_attribute("inputs:variantSetName")
db_value = database.inputs.variantSetName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_bundle"))
attribute = test_node.get_attribute("outputs_bundle")
db_value = database.outputs.bundle
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantString.py | import os
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.nodes.ogn.OgnConstantStringDatabase import OgnConstantStringDatabase
test_file_name = "OgnConstantStringTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantString")
database = OgnConstantStringDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetVariantNames.py | import os
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.nodes.ogn.OgnGetVariantNamesDatabase import OgnGetVariantNamesDatabase
test_file_name = "OgnGetVariantNamesTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetVariantNames")
database = OgnGetVariantNamesDatabase(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), 2)
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("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:variantSetName"))
attribute = test_node.get_attribute("inputs:variantSetName")
db_value = database.inputs.variantSetName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:variantNames"))
attribute = test_node.get_attribute("outputs:variantNames")
db_value = database.outputs.variantNames
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimRelationship.py | 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.nodes.ogn.OgnReadPrimRelationshipDatabase import OgnReadPrimRelationshipDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_nodes_ReadPrimRelationship", "omni.graph.nodes.ReadPrimRelationship")
})
database = OgnReadPrimRelationshipDatabase(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("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
self.assertTrue(test_node.get_attribute_exists("state:correctlySetup"))
attribute = test_node.get_attribute("state:correctlySetup")
db_value = database.state.correctlySetup
self.assertTrue(test_node.get_attribute_exists("state:name"))
attribute = test_node.get_attribute("state:name")
db_value = database.state.name
self.assertTrue(test_node.get_attribute_exists("state:prim"))
attribute = test_node.get_attribute("state:prim")
db_value = database.state.prim
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCopyAttr.py | import os
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.nodes.ogn.OgnCopyAttrDatabase import OgnCopyAttrDatabase
test_file_name = "OgnCopyAttrTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CopyAttribute")
database = OgnCopyAttrDatabase(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("inputs:fullData"))
attribute = test_node.get_attribute("inputs:fullData")
db_value = database.inputs.fullData
self.assertTrue(test_node.get_attribute_exists("inputs:inputAttrNames"))
attribute = test_node.get_attribute("inputs:inputAttrNames")
db_value = database.inputs.inputAttrNames
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:outputAttrNames"))
attribute = test_node.get_attribute("inputs:outputAttrNames")
db_value = database.inputs.outputAttrNames
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_data"))
attribute = test_node.get_attribute("outputs_data")
db_value = database.outputs.data
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrims.py | import os
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.nodes.ogn.OgnReadPrimsDatabase import OgnReadPrimsDatabase
test_file_name = "OgnReadPrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrims")
database = OgnReadPrimsDatabase(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), 3)
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("inputs:applySkelBinding"))
attribute = test_node.get_attribute("inputs:applySkelBinding")
db_value = database.inputs.applySkelBinding
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport"))
attribute = test_node.get_attribute("inputs:attrNamesToImport")
db_value = database.inputs.attrNamesToImport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:computeBoundingBox"))
attribute = test_node.get_attribute("inputs:computeBoundingBox")
db_value = database.inputs.computeBoundingBox
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useFindPrims"))
attribute = test_node.get_attribute("inputs:useFindPrims")
db_value = database.inputs.useFindPrims
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_primsBundle"))
attribute = test_node.get_attribute("outputs_primsBundle")
db_value = database.outputs.primsBundle
self.assertTrue(test_node.get_attribute_exists("state:applySkelBinding"))
attribute = test_node.get_attribute("state:applySkelBinding")
db_value = database.state.applySkelBinding
self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport"))
attribute = test_node.get_attribute("state:attrNamesToImport")
db_value = database.state.attrNamesToImport
self.assertTrue(test_node.get_attribute_exists("state:computeBoundingBox"))
attribute = test_node.get_attribute("state:computeBoundingBox")
db_value = database.state.computeBoundingBox
self.assertTrue(test_node.get_attribute_exists("state:pathPattern"))
attribute = test_node.get_attribute("state:pathPattern")
db_value = database.state.pathPattern
self.assertTrue(test_node.get_attribute_exists("state:primPaths"))
attribute = test_node.get_attribute("state:primPaths")
db_value = database.state.primPaths
self.assertTrue(test_node.get_attribute_exists("state:typePattern"))
attribute = test_node.get_attribute("state:typePattern")
db_value = database.state.typePattern
self.assertTrue(test_node.get_attribute_exists("state:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
self.assertTrue(test_node.get_attribute_exists("state:useFindPrims"))
attribute = test_node.get_attribute("state:useFindPrims")
db_value = database.state.useFindPrims
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadStageSelection.py | import os
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.nodes.ogn.OgnReadStageSelectionDatabase import OgnReadStageSelectionDatabase
test_file_name = "OgnReadStageSelectionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadStageSelection")
database = OgnReadStageSelectionDatabase(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:selectedPrims"))
attribute = test_node.get_attribute("outputs:selectedPrims")
db_value = database.outputs.selectedPrims
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnDivide.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'int64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'uint64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 42}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 42}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 42}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint', 'value': 42}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 42}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 42}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 42}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 42}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 42}, False],
['inputs:b', {'type': 'uint64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint', 'value': 42}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 42}, False],
['inputs:b', {'type': 'int64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double[3]', 'value': [0.5, 1.0, 1.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1.0, 2.0, 3.0, 4.0]}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double[4]', 'value': [0.5, 1.0, 1.5, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half[]', 'value': [1.0, 2.0, 3.0]}, False],
['inputs:b', {'type': 'uint64[]', 'value': [2, 4, 6]}, False],
],
'outputs': [
['outputs:result', {'type': 'half[]', 'value': [0.5, 0.5, 0.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'int[]', 'value': [2, 4, 6, 8]}, False],
],
'outputs': [
['outputs:result', {'type': 'double[]', 'value': [0.5, 0.5, 0.5, 0.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False],
['inputs:b', {'type': 'int[]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[1.0, 2.0], [1.5, 2.0]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:b', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 9.223372036854776e+18}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 3}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 3}, False],
['inputs:b', {'type': 'half', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half[2]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'half[2]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 10}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 5.0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Divide", "omni.graph.nodes.Divide", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Divide User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Divide","omni.graph.nodes.Divide", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Divide User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Divide", "omni.graph.nodes.Divide", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Divide User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnDivideDatabase import OgnDivideDatabase
test_file_name = "OgnDivideTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Divide")
database = OgnDivideDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantToken.py | import os
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.nodes.ogn.OgnConstantTokenDatabase import OgnConstantTokenDatabase
test_file_name = "OgnConstantTokenTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantToken")
database = OgnConstantTokenDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnClamp.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:input', {'type': 'int', 'value': 51038}, False],
['inputs:lower', {'type': 'int', 'value': -20}, False],
['inputs:upper', {'type': 'int', 'value': 5}, False],
],
'outputs': [
['outputs:result', {'type': 'int', 'value': 5}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [3.1415, -20.432, 50.762, -80.9, 5, 124]}, False],
['inputs:lower', {'type': 'float', 'value': -20}, False],
['inputs:upper', {'type': 'float', 'value': 50.4}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [3.1415, -20, 50.4, -20, 5, 50.4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[]', 'value': [1, 5, -2.5, 62]}, False],
['inputs:lower', {'type': 'double[]', 'value': [3, -10, -5, -10]}, False],
['inputs:upper', {'type': 'double[]', 'value': [5, 3.5, -5, 2]}, False],
],
'outputs': [
['outputs:result', {'type': 'double[]', 'value': [3, 3.5, -5, 2]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Clamp", "omni.graph.nodes.Clamp", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Clamp User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Clamp","omni.graph.nodes.Clamp", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Clamp User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Clamp", "omni.graph.nodes.Clamp", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Clamp User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnClampDatabase import OgnClampDatabase
test_file_name = "OgnClampTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Clamp")
database = OgnClampDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBreakVector4.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:tuple', {'type': 'float[4]', 'value': [42.0, 1.0, 2.0, 3.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
['outputs:z', {'type': 'float', 'value': 2.0}, False],
['outputs:w', {'type': 'float', 'value': 3.0}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'int[4]', 'value': [42, -42, 5, -5]}, False],
],
'outputs': [
['outputs:x', {'type': 'int', 'value': 42}, False],
['outputs:y', {'type': 'int', 'value': -42}, False],
['outputs:z', {'type': 'int', 'value': 5}, False],
['outputs:w', {'type': 'int', 'value': -5}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'quatd[4]', 'value': [42.0, 1.0, 2.0, 3.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'double', 'value': 42.0}, False],
['outputs:y', {'type': 'double', 'value': 1.0}, False],
['outputs:z', {'type': 'double', 'value': 2.0}, False],
['outputs:w', {'type': 'double', 'value': 3.0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector4", "omni.graph.nodes.BreakVector4", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector4 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector4","omni.graph.nodes.BreakVector4", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector4 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BreakVector4", "omni.graph.nodes.BreakVector4", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BreakVector4 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBreakVector4Database import OgnBreakVector4Database
test_file_name = "OgnBreakVector4Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BreakVector4")
database = OgnBreakVector4Database(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCrossProduct.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'half[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'half[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'half[3]', 'value': [-4, 8, -4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'float[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'float[3]', 'value': [-4, 8, -4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'double[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[3]', 'value': [-4, 8, -4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3][]', 'value': [[1, 2, 3], [10.2, 3.5, 7]]}, False],
['inputs:b', {'type': 'double[3][]', 'value': [[5, 6, 7], [5, 6.1, 4.2]]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[3][]', 'value': [[-4, 8, -4], [-28, -7.84, 44.72]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CrossProduct", "omni.graph.nodes.CrossProduct", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CrossProduct User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CrossProduct","omni.graph.nodes.CrossProduct", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CrossProduct User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_CrossProduct", "omni.graph.nodes.CrossProduct", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.CrossProduct User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCrossProductDatabase import OgnCrossProductDatabase
test_file_name = "OgnCrossProductTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CrossProduct")
database = OgnCrossProductDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetMatrix4Quaternion.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False],
],
'outputs': [
['outputs:quaternion', {'type': 'quatd[4]', 'value': [0.38268481, 0, 0, 0.9238804]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False],
],
'outputs': [
['outputs:quaternion', {'type': 'quatd[4][]', 'value': [[0.38268481, 0, 0, 0.9238804], [0.38268481, 0, 0, 0.9238804]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Quaternion", "omni.graph.nodes.GetMatrix4Quaternion", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Quaternion User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Quaternion","omni.graph.nodes.GetMatrix4Quaternion", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Quaternion User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_GetMatrix4Quaternion", "omni.graph.nodes.GetMatrix4Quaternion", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.GetMatrix4Quaternion User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetMatrix4QuaternionDatabase import OgnGetMatrix4QuaternionDatabase
test_file_name = "OgnGetMatrix4QuaternionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetMatrix4Quaternion")
database = OgnGetMatrix4QuaternionDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMoveToTarget.py | import os
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.nodes.ogn.OgnMoveToTargetDatabase import OgnMoveToTargetDatabase
test_file_name = "OgnMoveToTargetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MoveToTarget")
database = OgnMoveToTargetDatabase(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), 2)
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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:stop"))
attribute = test_node.get_attribute("inputs:stop")
db_value = database.inputs.stop
self.assertTrue(test_node.get_attribute_exists("inputs:useSourcePath"))
attribute = test_node.get_attribute("inputs:useSourcePath")
db_value = database.inputs.useSourcePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useTargetPath"))
attribute = test_node.get_attribute("inputs:useTargetPath")
db_value = database.inputs.useTargetPath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCreateTubeTopology.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:rows', [1, 2, 3], False],
['inputs:cols', [2, 3, 4], False],
],
'outputs': [
['outputs:faceVertexCounts', [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], False],
['outputs:faceVertexIndices', [0, 1, 3, 2, 1, 0, 2, 3, 4, 5, 8, 7, 5, 6, 9, 8, 6, 4, 7, 9, 7, 8, 11, 10, 8, 9, 12, 11, 9, 7, 10, 12, 13, 14, 18, 17, 14, 15, 19, 18, 15, 16, 20, 19, 16, 13, 17, 20, 17, 18, 22, 21, 18, 19, 23, 22, 19, 20, 24, 23, 20, 17, 21, 24, 21, 22, 26, 25, 22, 23, 27, 26, 23, 24, 28, 27, 24, 21, 25, 28], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CreateTubeTopology", "omni.graph.nodes.CreateTubeTopology", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CreateTubeTopology User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CreateTubeTopology","omni.graph.nodes.CreateTubeTopology", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CreateTubeTopology User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_CreateTubeTopology", "omni.graph.nodes.CreateTubeTopology", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.CreateTubeTopology User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCreateTubeTopologyDatabase import OgnCreateTubeTopologyDatabase
test_file_name = "OgnCreateTubeTopologyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CreateTubeTopology")
database = OgnCreateTubeTopologyDatabase(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("inputs:cols"))
attribute = test_node.get_attribute("inputs:cols")
db_value = database.inputs.cols
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:rows"))
attribute = test_node.get_attribute("inputs:rows")
db_value = database.inputs.rows
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:faceVertexCounts"))
attribute = test_node.get_attribute("outputs:faceVertexCounts")
db_value = database.outputs.faceVertexCounts
self.assertTrue(test_node.get_attribute_exists("outputs:faceVertexIndices"))
attribute = test_node.get_attribute("outputs:faceVertexIndices")
db_value = database.outputs.faceVertexIndices
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnEndsWith.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:value', "", False],
['inputs:suffix', "", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "a", False],
['inputs:suffix', "", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "", False],
['inputs:suffix', "a", False],
],
'outputs': [
['outputs:isSuffix', False, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:suffix', "a", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "ab", False],
['inputs:suffix', "ab", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:suffix', "aaa", False],
],
'outputs': [
['outputs:isSuffix', False, False],
],
},
{
'inputs': [
['inputs:value', "aba", False],
['inputs:suffix', "ba", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EndsWith", "omni.graph.nodes.EndsWith", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EndsWith User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EndsWith","omni.graph.nodes.EndsWith", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EndsWith User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_EndsWith", "omni.graph.nodes.EndsWith", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.EndsWith User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnEndsWithDatabase import OgnEndsWithDatabase
test_file_name = "OgnEndsWithTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_EndsWith")
database = OgnEndsWithDatabase(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("inputs:suffix"))
attribute = test_node.get_attribute("inputs:suffix")
db_value = database.inputs.suffix
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:isSuffix"))
attribute = test_node.get_attribute("outputs:isSuffix")
db_value = database.outputs.isSuffix
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnScaleToSize.py | import os
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.nodes.ogn.OgnScaleToSizeDatabase import OgnScaleToSizeDatabase
test_file_name = "OgnScaleToSizeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ScaleToSize")
database = OgnScaleToSizeDatabase(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), 2)
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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:stop"))
attribute = test_node.get_attribute("inputs:stop")
db_value = database.inputs.stop
self.assertTrue(test_node.get_attribute_exists("inputs:target"))
attribute = test_node.get_attribute("inputs:target")
db_value = database.inputs.target
expected_value = [0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usePath"))
attribute = test_node.get_attribute("inputs:usePath")
db_value = database.inputs.usePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantTexCoord2h.py | import os
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.nodes.ogn.OgnConstantTexCoord2hDatabase import OgnConstantTexCoord2hDatabase
test_file_name = "OgnConstantTexCoord2hTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantTexCoord2h")
database = OgnConstantTexCoord2hDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomNumeric.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6649909271, False],
['inputs:min', {'type': 'uint', 'value': 0}, False],
['inputs:max', {'type': 'uint', 'value': 4294967295}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6159018942, False],
['inputs:min', {'type': 'uint[]', 'value': [0, 100]}, False],
['inputs:max', {'type': 'uint', 'value': 4294967295}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint[]', 'value': [2147483648, 2160101208]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 3280530163, False],
['inputs:min', {'type': 'uint', 'value': 0}, False],
['inputs:max', {'type': 'uint[]', 'value': [4294967295, 199]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint[]', 'value': [4294967295, 19]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6159018942, False],
['inputs:min', {'type': 'int', 'value': -2147483648}, False],
['inputs:max', {'type': 'int', 'value': 2147483647}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'int', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6649909271, False],
['inputs:min', {'type': 'int[2]', 'value': [-2147483648, -100]}, False],
['inputs:max', {'type': 'int', 'value': 2147483647}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'int[2]', 'value': [-2147483648, 1629773655]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 3280530163, False],
['inputs:min', {'type': 'int', 'value': -2147483648}, False],
['inputs:max', {'type': 'int[2]', 'value': [2147483647, 99]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'int[2]', 'value': [2147483647, -2146948710]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 8280086, False],
['inputs:min', {'type': 'float', 'value': 0}, False],
['inputs:max', {'type': 'float', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 17972581, False],
['inputs:min', {'type': 'float[]', 'value': [0, -10]}, False],
['inputs:max', {'type': 'float', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[]', 'value': [0.5, -6.7663326]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 15115159, False],
['inputs:min', {'type': 'float', 'value': 0}, False],
['inputs:max', {'type': 'float[]', 'value': [1, 10]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[]', 'value': [0.9999999403953552, 4.0452986]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 14092058508772706262, False],
['inputs:min', {'type': 'uint64', 'value': 0}, False],
['inputs:max', {'type': 'uint64', 'value': 18446744073709551615}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 9302349107990861236, False],
['inputs:min', {'type': 'uint64', 'value': 0}, False],
['inputs:max', {'type': 'uint64', 'value': 18446744073709551615}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 9223372036854775808}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 1955209015103813879, False],
['inputs:min', {'type': 'uint64', 'value': 0}, False],
['inputs:max', {'type': 'uint64', 'value': 18446744073709551615}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 18446744073709551615}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:min', {'type': 'uint64', 'value': 1099511627776}, False],
['inputs:max', {'type': 'uint64', 'value': 1125899906842624}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 923489197424953}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 1955209015103813879, False],
['inputs:min', {'type': 'double[2][]', 'value': [[0, -10], [10, 0]]}, False],
['inputs:max', {'type': 'double', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'double[2][]', 'value': [[0, 0.28955788], [7.98645811, 0.09353537]]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:min', {'type': 'half[]', 'value': [0, -100]}, False],
['inputs:max', {'type': 'half[]', 'value': [1, 100]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'half[]', 'value': [0.17993164, -76.375]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 0, False],
['inputs:min', {'type': 'uchar[]', 'value': [0, 100]}, False],
['inputs:max', {'type': 'uchar[]', 'value': [255, 200]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uchar[]', 'value': [153, 175]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 9302349107990861236, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'double', 'value': 0.5}, False],
['outputs:execOut', 1, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomNumeric", "omni.graph.nodes.RandomNumeric", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomNumeric User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomNumeric","omni.graph.nodes.RandomNumeric", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomNumeric User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RandomNumeric", "omni.graph.nodes.RandomNumeric", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RandomNumeric User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomNumericDatabase import OgnRandomNumericDatabase
test_file_name = "OgnRandomNumericTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RandomNumeric")
database = OgnRandomNumericDatabase(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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:isNoise"))
attribute = test_node.get_attribute("inputs:isNoise")
db_value = database.inputs.isNoise
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useSeed"))
attribute = test_node.get_attribute("inputs:useSeed")
db_value = database.inputs.useSeed
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("state:gen"))
attribute = test_node.get_attribute("state:gen")
db_value = database.state.gen
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMagnitude.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:input', {'type': 'double', 'value': -10.0}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float', 'value': -10.0}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half', 'value': -10.0}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int', 'value': -10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int64', 'value': -10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int64', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar', 'value': 10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uchar', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint', 'value': 10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint64', 'value': 10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint64', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[2]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double', 'value': 5.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[3]', 'value': [1.0, 2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double', 'value': 3.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[4]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float', 'value': 4.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[2]', 'value': [3.0, -4.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half', 'value': 5.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[]', 'value': [1.0, 2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double[]', 'value': [1.0, 2.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float[]', 'value': [2.0, 2.0, 2.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[]', 'value': [3.0, -4.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half[]', 'value': [3.0, 4.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int64[]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int64[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uchar[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint64[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint64[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[3][]', 'value': [[1, 2, 2], [4, 2, 6], [3, 2, 4], [1, -4, 2]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double[]', 'value': [3.0, 7.483314773547883, 5.385164807134504, 4.58257569495584]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double[]', 'value': [3.0, 7.483314773547883, 5.385164807134504, 4.58257569495584]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float[]', 'value': [3.0, 7.483315, 5.3851647, 4.582576]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half[]', 'value': [3.0, 7.484375, 5.3867188, 4.5820312]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Magnitude", "omni.graph.nodes.Magnitude", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Magnitude User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Magnitude","omni.graph.nodes.Magnitude", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Magnitude User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Magnitude", "omni.graph.nodes.Magnitude", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Magnitude User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMagnitudeDatabase import OgnMagnitudeDatabase
test_file_name = "OgnMagnitudeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Magnitude")
database = OgnMagnitudeDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGatherByPath.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
import os
class TestOgn(ogts.OmniGraphTestCase):
async def test_generated(self):
test_data = [{'inputs': [['inputs:primPaths', ['/Xform1', '/Xform2'], False], ['inputs:attributes', '_translate', False], ['inputs:allAttributes', False, False]], 'outputs': [['outputs:gatheredPaths', ['/Xform1', '/Xform2'], False], ['outputs:gatherId', 1, False]], 'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.GatherByPath']], 'create_prims': [['Empty', {}], ['Xform1', {'_translate': ['pointd[3]', [1, 2, 3]]}], ['Xform2', {'_translate': ['pointd[3]', [4, 5, 6]]}], ['XformTagged1', {'foo': ['token', ''], '_translate': ['pointd[3]', [1, 2, 3]]}], ['Tagged1', {'foo': ['token', '']}]]}}, {'inputs': [['inputs:primPaths', ['/XformTagged1', '/Xform2', '/Xform1'], False], ['inputs:attributes', '_translate', False], ['inputs:allAttributes', False, False]], 'outputs': [['outputs:gatheredPaths', ['/XformTagged1', '/Xform1', '/Xform2'], False]], 'setup': {}}]
test_node = None
test_graph = None
for i, test_run in enumerate(test_data):
inputs = test_run.get('inputs', [])
outputs = test_run.get('outputs', [])
state_set = test_run.get('state_set', [])
state_get = test_run.get('state_get', [])
setup = test_run.get('setup', None)
if setup is None or setup:
await omni.usd.get_context().new_stage_async()
test_graph = None
elif not setup:
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test is misconfigured - empty setup cannot be in the first test")
if setup:
(test_graph, test_nodes, _, _) = og.Controller.edit("/TestGraph", setup)
self.assertTrue(test_nodes)
test_node = test_nodes[0]
elif setup is None:
if test_graph is None:
test_graph = og.Controller.create_graph("/TestGraph")
self.assertTrue(test_graph is not None and test_graph.is_valid())
test_node = og.Controller.create_node(
("TestNode_omni_graph_nodes_GatherByPath", test_graph), "omni.graph.nodes.GatherByPath"
)
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test graph invalid")
self.assertTrue(test_node is not None and test_node.is_valid(), "Test node invalid")
await og.Controller.evaluate(test_graph)
values_to_set = inputs + state_set
if values_to_set:
for attribute_name, attribute_value, _ in inputs + state_set:
og.Controller((attribute_name, test_node)).set(attribute_value)
await og.Controller.evaluate(test_graph)
for attribute_name, expected_value, _ in outputs + state_get:
attribute = og.Controller.attribute(attribute_name, test_node)
actual_output = og.Controller.get(attribute)
expected_type = None
if isinstance(expected_value, dict):
expected_type = expected_value["type"]
expected_value = expected_value["value"]
ogts.verify_values(expected_value, actual_output, f"omni.graph.nodes.GatherByPath User test case #{i+1}: {attribute_name} attribute value error")
if expected_type:
tp = og.AttributeType.type_from_ogn_type_name(expected_type)
actual_type = attribute.get_resolved_type()
if tp != actual_type:
raise ValueError(f"omni.graph.nodes.GatherByPath User tests - {attribute_name}: Expected {expected_type}, saw {actual_type.get_ogn_type_name()}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGatherByPathDatabase import OgnGatherByPathDatabase
test_file_name = "OgnGatherByPathTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GatherByPath")
database = OgnGatherByPathDatabase(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("inputs:allAttributes"))
attribute = test_node.get_attribute("inputs:allAttributes")
db_value = database.inputs.allAttributes
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:attributes"))
attribute = test_node.get_attribute("inputs:attributes")
db_value = database.inputs.attributes
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:checkResyncAttributes"))
attribute = test_node.get_attribute("inputs:checkResyncAttributes")
db_value = database.inputs.checkResyncAttributes
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:forceExportToHistory"))
attribute = test_node.get_attribute("inputs:forceExportToHistory")
db_value = database.inputs.forceExportToHistory
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:hydraFastPath"))
attribute = test_node.get_attribute("inputs:hydraFastPath")
db_value = database.inputs.hydraFastPath
expected_value = "Disabled"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:primPaths"))
attribute = test_node.get_attribute("inputs:primPaths")
db_value = database.inputs.primPaths
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:shouldWriteBack"))
attribute = test_node.get_attribute("inputs:shouldWriteBack")
db_value = database.inputs.shouldWriteBack
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:gatherId"))
attribute = test_node.get_attribute("outputs:gatherId")
db_value = database.outputs.gatherId
self.assertTrue(test_node.get_attribute_exists("outputs:gatheredPaths"))
attribute = test_node.get_attribute("outputs:gatheredPaths")
db_value = database.outputs.gatheredPaths
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPoint3d.py | import os
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.nodes.ogn.OgnConstantPoint3dDatabase import OgnConstantPoint3dDatabase
test_file_name = "OgnConstantPoint3dTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantPoint3d")
database = OgnConstantPoint3dDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnModulo.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 4}, False],
['inputs:b', {'type': 'uint64', 'value': 3}, False],
],
'outputs': [
['outputs:result', {'type': 'uint64', 'value': 1}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 4}, False],
['inputs:b', {'type': 'int', 'value': 0}, False],
],
'outputs': [
['outputs:result', {'type': 'int', 'value': 0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Modulo", "omni.graph.nodes.Modulo", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Modulo User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Modulo","omni.graph.nodes.Modulo", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Modulo User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Modulo", "omni.graph.nodes.Modulo", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Modulo User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnModuloDatabase import OgnModuloDatabase
test_file_name = "OgnModuloTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Modulo")
database = OgnModuloDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble.py | import os
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.nodes.ogn.OgnConstantDoubleDatabase import OgnConstantDoubleDatabase
test_file_name = "OgnConstantDoubleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantDouble")
database = OgnConstantDoubleDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrims.py | import os
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.nodes.ogn.OgnWritePrimsDatabase import OgnWritePrimsDatabase
test_file_name = "OgnWritePrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrims")
database = OgnWritePrimsDatabase(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("inputs:attrNamesToExport"))
attribute = test_node.get_attribute("inputs:attrNamesToExport")
db_value = database.inputs.attrNamesToExport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:primsBundle"))
attribute = test_node.get_attribute("inputs:primsBundle")
db_value = database.inputs.primsBundle
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack"))
attribute = test_node.get_attribute("inputs:usdWriteBack")
db_value = database.inputs.usdWriteBack
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetParentPrims.py | import os
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.nodes.ogn.OgnGetParentPrimsDatabase import OgnGetParentPrimsDatabase
test_file_name = "OgnGetParentPrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetParentPrims")
database = OgnGetParentPrimsDatabase(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("inputs:prims"))
attribute = test_node.get_attribute("inputs:prims")
db_value = database.inputs.prims
self.assertTrue(test_node.get_attribute_exists("outputs:parentPrims"))
attribute = test_node.get_attribute("outputs:parentPrims")
db_value = database.outputs.parentPrims
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeVector2.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
['inputs:y', {'type': 'float', 'value': 1.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[2]', 'value': [42.0, 1.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[2]', 'value': [42.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float[]', 'value': [42, 1, 0]}, False],
['inputs:y', {'type': 'float[]', 'value': [0, 1, 2]}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[2][]', 'value': [[42, 0], [1, 1], [0, 2]]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'int', 'value': 42}, False],
['inputs:y', {'type': 'int', 'value': -42}, False],
],
'outputs': [
['outputs:tuple', {'type': 'int[2]', 'value': [42, -42]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector2", "omni.graph.nodes.MakeVector2", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector2 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector2","omni.graph.nodes.MakeVector2", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector2 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeVector2", "omni.graph.nodes.MakeVector2", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeVector2 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeVector2Database import OgnMakeVector2Database
test_file_name = "OgnMakeVector2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeVector2")
database = OgnMakeVector2Database(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimer.py | import os
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.nodes.ogn.OgnTimerDatabase import OgnTimerDatabase
test_file_name = "OgnTimerTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Timer")
database = OgnTimerDatabase(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), 2)
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("inputs:duration"))
attribute = test_node.get_attribute("inputs:duration")
db_value = database.inputs.duration
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:endValue"))
attribute = test_node.get_attribute("inputs:endValue")
db_value = database.inputs.endValue
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:play"))
attribute = test_node.get_attribute("inputs:play")
db_value = database.inputs.play
self.assertTrue(test_node.get_attribute_exists("inputs:startValue"))
attribute = test_node.get_attribute("inputs:startValue")
db_value = database.inputs.startValue
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
self.assertTrue(test_node.get_attribute_exists("outputs:updated"))
attribute = test_node.get_attribute("outputs:updated")
db_value = database.outputs.updated
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrimRelationship.py | 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.nodes.ogn.OgnWritePrimRelationshipDatabase import OgnWritePrimRelationshipDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_nodes_WritePrimRelationship", "omni.graph.nodes.WritePrimRelationship")
})
database = OgnWritePrimRelationshipDatabase(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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack"))
attribute = test_node.get_attribute("inputs:usdWriteBack")
db_value = database.inputs.usdWriteBack
expected_value = True
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("state:correctlySetup"))
attribute = test_node.get_attribute("state:correctlySetup")
db_value = database.state.correctlySetup
self.assertTrue(test_node.get_attribute_exists("state:name"))
attribute = test_node.get_attribute("state:name")
db_value = database.state.name
self.assertTrue(test_node.get_attribute_exists("state:prim"))
attribute = test_node.get_attribute("state:prim")
db_value = database.state.prim
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimsV2.py | import os
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.nodes.ogn.OgnReadPrimsV2Database import OgnReadPrimsV2Database
test_file_name = "OgnReadPrimsV2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrimsV2")
database = OgnReadPrimsV2Database(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("inputs:_debugStamp"))
attribute = test_node.get_attribute("inputs:_debugStamp")
db_value = database.inputs._debugStamp
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:applySkelBinding"))
attribute = test_node.get_attribute("inputs:applySkelBinding")
db_value = database.inputs.applySkelBinding
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport"))
attribute = test_node.get_attribute("inputs:attrNamesToImport")
db_value = database.inputs.attrNamesToImport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:computeBoundingBox"))
attribute = test_node.get_attribute("inputs:computeBoundingBox")
db_value = database.inputs.computeBoundingBox
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:enableBundleChangeTracking"))
attribute = test_node.get_attribute("inputs:enableBundleChangeTracking")
db_value = database.inputs.enableBundleChangeTracking
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:enableChangeTracking"))
attribute = test_node.get_attribute("inputs:enableChangeTracking")
db_value = database.inputs.enableChangeTracking
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prims"))
attribute = test_node.get_attribute("inputs:prims")
db_value = database.inputs.prims
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_primsBundle"))
attribute = test_node.get_attribute("outputs_primsBundle")
db_value = database.outputs.primsBundle
self.assertTrue(test_node.get_attribute_exists("state:applySkelBinding"))
attribute = test_node.get_attribute("state:applySkelBinding")
db_value = database.state.applySkelBinding
self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport"))
attribute = test_node.get_attribute("state:attrNamesToImport")
db_value = database.state.attrNamesToImport
self.assertTrue(test_node.get_attribute_exists("state:computeBoundingBox"))
attribute = test_node.get_attribute("state:computeBoundingBox")
db_value = database.state.computeBoundingBox
self.assertTrue(test_node.get_attribute_exists("state:enableBundleChangeTracking"))
attribute = test_node.get_attribute("state:enableBundleChangeTracking")
db_value = database.state.enableBundleChangeTracking
self.assertTrue(test_node.get_attribute_exists("state:enableChangeTracking"))
attribute = test_node.get_attribute("state:enableChangeTracking")
db_value = database.state.enableChangeTracking
self.assertTrue(test_node.get_attribute_exists("state:pathPattern"))
attribute = test_node.get_attribute("state:pathPattern")
db_value = database.state.pathPattern
self.assertTrue(test_node.get_attribute_exists("state:typePattern"))
attribute = test_node.get_attribute("state:typePattern")
db_value = database.state.typePattern
self.assertTrue(test_node.get_attribute_exists("state:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCurveFrame.py | import os
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.nodes.ogn.OgnCurveFrameDatabase import OgnCurveFrameDatabase
test_file_name = "OgnCurveFrameTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CurveToFrame")
database = OgnCurveFrameDatabase(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("inputs:curvePoints"))
attribute = test_node.get_attribute("inputs:curvePoints")
db_value = database.inputs.curvePoints
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexCounts"))
attribute = test_node.get_attribute("inputs:curveVertexCounts")
db_value = database.inputs.curveVertexCounts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexStarts"))
attribute = test_node.get_attribute("inputs:curveVertexStarts")
db_value = database.inputs.curveVertexStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:out"))
attribute = test_node.get_attribute("outputs:out")
db_value = database.outputs.out
self.assertTrue(test_node.get_attribute_exists("outputs:tangent"))
attribute = test_node.get_attribute("outputs:tangent")
db_value = database.outputs.tangent
self.assertTrue(test_node.get_attribute_exists("outputs:up"))
attribute = test_node.get_attribute("outputs:up")
db_value = database.outputs.up
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantFloat2.py | import os
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.nodes.ogn.OgnConstantFloat2Database import OgnConstantFloat2Database
test_file_name = "OgnConstantFloat2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantFloat2")
database = OgnConstantFloat2Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimAttribute.py | 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.nodes.ogn.OgnReadPrimAttributeDatabase import OgnReadPrimAttributeDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_nodes_ReadPrimAttribute", "omni.graph.nodes.ReadPrimAttribute")
})
database = OgnReadPrimAttributeDatabase(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), 3)
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("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usePath"))
attribute = test_node.get_attribute("inputs:usePath")
db_value = database.inputs.usePath
expected_value = False
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("state:correctlySetup"))
attribute = test_node.get_attribute("state:correctlySetup")
db_value = database.state.correctlySetup
self.assertTrue(test_node.get_attribute_exists("state:importPath"))
attribute = test_node.get_attribute("state:importPath")
db_value = database.state.importPath
self.assertTrue(test_node.get_attribute_exists("state:srcAttrib"))
attribute = test_node.get_attribute("state:srcAttrib")
db_value = database.state.srcAttrib
self.assertTrue(test_node.get_attribute_exists("state:srcPath"))
attribute = test_node.get_attribute("state:srcPath")
db_value = database.state.srcPath
self.assertTrue(test_node.get_attribute_exists("state:srcPathAsToken"))
attribute = test_node.get_attribute("state:srcPathAsToken")
db_value = database.state.srcPathAsToken
self.assertTrue(test_node.get_attribute_exists("state:time"))
attribute = test_node.get_attribute("state:time")
db_value = database.state.time
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayIndex.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [42]}, False],
['inputs:index', 0, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 42}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'float[2][]', 'value': [[1.0, 2.0]]}, False],
['inputs:index', 0, False],
],
'outputs': [
['outputs:value', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 2}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', -1, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 3}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', -2, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 2}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', 2, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 3}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['foo', 'bar']}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'token', 'value': 'bar'}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [True, False, False]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'pointd[3][]', 'value': [[1, 2, 3], [4, 5, 6]]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'pointd[3]', 'value': [4, 5, 6]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayIndex", "omni.graph.nodes.ArrayIndex", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayIndex User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayIndex","omni.graph.nodes.ArrayIndex", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayIndex User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayIndex", "omni.graph.nodes.ArrayIndex", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayIndex User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayIndexDatabase import OgnArrayIndexDatabase
test_file_name = "OgnArrayIndexTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayIndex")
database = OgnArrayIndexDatabase(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("inputs:index"))
attribute = test_node.get_attribute("inputs:index")
db_value = database.inputs.index
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTranslateToTarget.py | import os
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.nodes.ogn.OgnTranslateToTargetDatabase import OgnTranslateToTargetDatabase
test_file_name = "OgnTranslateToTargetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_TranslateToTarget")
database = OgnTranslateToTargetDatabase(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), 2)
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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:stop"))
attribute = test_node.get_attribute("inputs:stop")
db_value = database.inputs.stop
self.assertTrue(test_node.get_attribute_exists("inputs:useSourcePath"))
attribute = test_node.get_attribute("inputs:useSourcePath")
db_value = database.inputs.useSourcePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useTargetPath"))
attribute = test_node.get_attribute("inputs:useTargetPath")
db_value = database.inputs.useTargetPath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeVector3.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
['inputs:y', {'type': 'float', 'value': 1.0}, False],
['inputs:z', {'type': 'float', 'value': 0.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[3]', 'value': [42.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float[]', 'value': [42, 1, 0]}, False],
['inputs:y', {'type': 'float[]', 'value': [0, 1, 2]}, False],
['inputs:z', {'type': 'float[]', 'value': [0, 2, 4]}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[3][]', 'value': [[42, 0, 0], [1, 1, 2], [0, 2, 4]]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'int', 'value': 42}, False],
['inputs:y', {'type': 'int', 'value': -42}, False],
['inputs:z', {'type': 'int', 'value': 5}, False],
],
'outputs': [
['outputs:tuple', {'type': 'int[3]', 'value': [42, -42, 5]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'double', 'value': 42.0}, False],
['inputs:y', {'type': 'double', 'value': 1.0}, False],
['inputs:z', {'type': 'double', 'value': 0.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'pointd[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.MakeVector3'], ['ConstPoint3d', 'omni.graph.nodes.ConstantPoint3d']], 'connect': [['TestNode.outputs:tuple', 'ConstPoint3d.inputs:value']]} },
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector3", "omni.graph.nodes.MakeVector3", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector3 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector3","omni.graph.nodes.MakeVector3", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector3 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeVector3", "omni.graph.nodes.MakeVector3", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeVector3 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeVector3Database import OgnMakeVector3Database
test_file_name = "OgnMakeVector3Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeVector3")
database = OgnMakeVector3Database(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWriteVariable.py | import os
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.nodes.ogn.OgnWriteVariableDatabase import OgnWriteVariableDatabase
test_file_name = "OgnWriteVariableTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_core_WriteVariable")
database = OgnWriteVariableDatabase(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), 2)
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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:variableName"))
attribute = test_node.get_attribute("inputs:variableName")
db_value = database.inputs.variableName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayFindValue.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOO'}, False],
],
'outputs': [
['outputs:index', -1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOOD'}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'int64', 'value': 41}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uchar[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uchar', 'value': 41}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint', 'value': 42}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint64', 'value': 42}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:value', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:value', {'type': 'half[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.0], [3, 4, 5]]}, False],
['inputs:value', {'type': 'double[3]', 'value': [3, 4, 5]}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[4][]', 'value': [[1, 2, 3, 4], [3, 4, 5, 6]]}, False],
['inputs:value', {'type': 'int[4]', 'value': [1, 2, 3, 4]}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayFindValue", "omni.graph.nodes.ArrayFindValue", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayFindValue User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayFindValue","omni.graph.nodes.ArrayFindValue", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayFindValue User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayFindValue", "omni.graph.nodes.ArrayFindValue", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayFindValue User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayFindValueDatabase import OgnArrayFindValueDatabase
test_file_name = "OgnArrayFindValueTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayFindValue")
database = OgnArrayFindValueDatabase(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:index"))
attribute = test_node.get_attribute("outputs:index")
db_value = database.outputs.index
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMultiply.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:product', {'type': 'float', 'value': 84.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2]', 'value': [1.0, 42.0]}, False],
['inputs:b', {'type': 'double[2]', 'value': [2.0, 1.0]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2]', 'value': [2.0, 42.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[]', 'value': [1.0, 42.0]}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:product', {'type': 'double[]', 'value': [2.0, 84.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:b', {'type': 'double[2]', 'value': [5, 5]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2][]', 'value': [[50, 25], [5, 5]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:b', {'type': 'double', 'value': 2}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2][]', 'value': [[20, 10], [2, 2]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2]', 'value': [10, 5]}, False],
['inputs:b', {'type': 'double', 'value': 2}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2]', 'value': [20, 10]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Multiply", "omni.graph.nodes.Multiply", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Multiply User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Multiply","omni.graph.nodes.Multiply", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Multiply User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Multiply", "omni.graph.nodes.Multiply", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Multiply User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMultiplyDatabase import OgnMultiplyDatabase
test_file_name = "OgnMultiplyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Multiply")
database = OgnMultiplyDatabase(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), 2)
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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineLoop.py | import os
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.nodes.ogn.OgnTimelineLoopDatabase import OgnTimelineLoopDatabase
test_file_name = "OgnTimelineLoopTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_LoopTimeline")
database = OgnTimelineLoopDatabase(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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:loop"))
attribute = test_node.get_attribute("inputs:loop")
db_value = database.inputs.loop
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBreakVector2.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:tuple', {'type': 'float[2]', 'value': [42.0, 1.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'int[2]', 'value': [42, -42]}, False],
],
'outputs': [
['outputs:x', {'type': 'int', 'value': 42}, False],
['outputs:y', {'type': 'int', 'value': -42}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector2", "omni.graph.nodes.BreakVector2", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector2 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector2","omni.graph.nodes.BreakVector2", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector2 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BreakVector2", "omni.graph.nodes.BreakVector2", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BreakVector2 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBreakVector2Database import OgnBreakVector2Database
test_file_name = "OgnBreakVector2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BreakVector2")
database = OgnBreakVector2Database(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSelectIf.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:ifTrue', {'type': 'float', 'value': 1.0}, False],
['inputs:ifFalse', {'type': 'float', 'value': 3.0}, False],
['inputs:condition', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 1.0}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float', 'value': 1.0}, False],
['inputs:ifFalse', {'type': 'float', 'value': 3.0}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 3.0}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float[]', 'value': [10.0, 20.0]}, False],
['inputs:ifFalse', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [10.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float[]', 'value': [10.0, 20.0]}, False],
['inputs:ifFalse', {'type': 'float', 'value': 99}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [10.0, 99]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float', 'value': 99}, False],
['inputs:ifFalse', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [99, 2.0]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float[2][]', 'value': [[1, 1], [2, 2]]}, False],
['inputs:ifFalse', {'type': 'float[2][]', 'value': [[3, 3], [4, 4]]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[1, 1], [4, 4]]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'string', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'string', 'value': 'efghi'}, False],
['inputs:condition', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', {'type': 'string', 'value': 'abc'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'string', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'string', 'value': 'efg'}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'string', 'value': 'efg'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'uchar[]', 'value': [61, 62, 63]}, False],
['inputs:ifFalse', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'uchar[]', 'value': [61, 62, 63]}, False],
['inputs:ifFalse', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False, True]}, False],
],
'outputs': [
['outputs:result', {'type': 'uchar[]', 'value': [61, 66, 63]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'token', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'token', 'value': 'efghi'}, False],
['inputs:condition', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', {'type': 'token', 'value': 'abc'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'token', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'token', 'value': 'efghi'}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'token', 'value': 'efghi'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'token[]', 'value': ['ab', 'cd']}, False],
['inputs:ifFalse', {'type': 'token[]', 'value': ['ef', 'gh']}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'token[]', 'value': ['ab', 'gh']}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SelectIf", "omni.graph.nodes.SelectIf", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SelectIf User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SelectIf","omni.graph.nodes.SelectIf", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SelectIf User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SelectIf", "omni.graph.nodes.SelectIf", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SelectIf User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSelectIfDatabase import OgnSelectIfDatabase
test_file_name = "OgnSelectIfTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SelectIf")
database = OgnSelectIfDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCos.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 45.0}, False],
],
'outputs': [
['outputs:value', {'type': 'float', 'value': 0.707107}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 120.0}, False],
],
'outputs': [
['outputs:value', {'type': 'double', 'value': -0.5}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Cos", "omni.graph.nodes.Cos", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Cos User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Cos","omni.graph.nodes.Cos", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Cos User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Cos", "omni.graph.nodes.Cos", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Cos User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCosDatabase import OgnCosDatabase
test_file_name = "OgnCosTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Cos")
database = OgnCosDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble2.py | import os
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.nodes.ogn.OgnConstantDouble2Database import OgnConstantDouble2Database
test_file_name = "OgnConstantDouble2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantDouble2")
database = OgnConstantDouble2Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeTransform.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:rotationXYZ', [0, 0, 0], False],
['inputs:translation', [0, 0, 0], False],
],
'outputs': [
['outputs:transform', [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], False],
],
},
{
'inputs': [
['inputs:rotationXYZ', [0, 0, 0], False],
['inputs:translation', [1, 2, 3], False],
],
'outputs': [
['outputs:transform', [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1], False],
],
},
{
'inputs': [
['inputs:rotationXYZ', [20, 0, 30], False],
['inputs:translation', [1, -2, 3], False],
],
'outputs': [
['outputs:transform', [0.866025404, 0.5, 4.16333634e-17, 0.0, -0.46984631, 0.813797681, 0.342020143, 0.0, 0.171010072, -0.296198133, 0.939692621, 0.0, 1.0, -2.0, 3.0, 1.0], False],
],
},
{
'inputs': [
['inputs:scale', [10, 5, 2], False],
],
'outputs': [
['outputs:transform', [10, 0, 0, 0, 0, 5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1], False],
],
},
{
'inputs': [
['inputs:translation', [1, -2, 3], False],
['inputs:rotationXYZ', [20, 0, 30], False],
['inputs:scale', [10, 5, 2], False],
],
'outputs': [
['outputs:transform', [8.66025404, 5.0, 0.0, 0.0, -2.34923155, 4.06898841, 1.71010072, 0.0, 0.34202014, -0.59239627, 1.87938524, 0.0, 1.0, -2.0, 3.0, 1.0], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeTransform", "omni.graph.nodes.MakeTransform", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransform User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeTransform","omni.graph.nodes.MakeTransform", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransform User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeTransform", "omni.graph.nodes.MakeTransform", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeTransform User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeTransformDatabase import OgnMakeTransformDatabase
test_file_name = "OgnMakeTransformTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeTransform")
database = OgnMakeTransformDatabase(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("inputs:rotationXYZ"))
attribute = test_node.get_attribute("inputs:rotationXYZ")
db_value = database.inputs.rotationXYZ
expected_value = [0, 0, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:scale"))
attribute = test_node.get_attribute("inputs:scale")
db_value = database.inputs.scale
expected_value = [1, 1, 1]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:translation"))
attribute = test_node.get_attribute("inputs:translation")
db_value = database.inputs.translation
expected_value = [0, 0, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:transform"))
attribute = test_node.get_attribute("outputs:transform")
db_value = database.outputs.transform
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWriteSetting.py | import os
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.nodes.ogn.OgnWriteSettingDatabase import OgnWriteSettingDatabase
test_file_name = "OgnWriteSettingTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WriteSetting")
database = OgnWriteSettingDatabase(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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:settingPath"))
attribute = test_node.get_attribute("inputs:settingPath")
db_value = database.inputs.settingPath
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToString.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:converted', "True", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.1}, False],
],
'outputs': [
['outputs:converted', "2.1", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:converted', "42", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[3]', 'value': [1.5, 2, 3]}, False],
],
'outputs': [
['outputs:converted', "[1.5, 2, 3]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3]', 'value': [2, 3.5, 4]}, False],
],
'outputs': [
['outputs:converted', "[2, 3.5, 4]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2][]', 'value': [[1, 2], [3, 4]]}, False],
],
'outputs': [
['outputs:converted', "[[1, 2], [3, 4]]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uint64', 'value': 42}, False],
],
'outputs': [
['outputs:converted', "42", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uchar', 'value': 65}, False],
],
'outputs': [
['outputs:converted', "A", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
],
'outputs': [
['outputs:converted', "[A, B, C]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'string', 'value': 'ABC'}, False],
],
'outputs': [
['outputs:converted', "ABC", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token', 'value': 'Foo'}, False],
],
'outputs': [
['outputs:converted', "Foo", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token', 'value': ''}, False],
],
'outputs': [
['outputs:converted', "", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token[]', 'value': ['Foo', 'Bar']}, False],
],
'outputs': [
['outputs:converted', "[\"Foo\", \"Bar\"]", False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToString", "omni.graph.nodes.ToString", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToString User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToString","omni.graph.nodes.ToString", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToString User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToString", "omni.graph.nodes.ToString", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToString User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToStringDatabase import OgnToStringDatabase
test_file_name = "OgnToStringTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToString")
database = OgnToStringDatabase(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:converted"))
attribute = test_node.get_attribute("outputs:converted")
db_value = database.outputs.converted
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIsEmpty.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:input', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int', 'value': 0}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double', 'value': 0.0}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar', 'value': 0}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[2]', 'value': [0.0, 0.0]}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [0.0]}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': []}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[]', 'value': []}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[2][]', 'value': []}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'token', 'value': 'hello'}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'string', 'value': 'hello'}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'token', 'value': ' '}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'string', 'value': ' '}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'string', 'value': ''}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'token', 'value': ''}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_IsEmpty", "omni.graph.nodes.IsEmpty", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.IsEmpty User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_IsEmpty","omni.graph.nodes.IsEmpty", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.IsEmpty User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_IsEmpty", "omni.graph.nodes.IsEmpty", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.IsEmpty User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnIsEmptyDatabase import OgnIsEmptyDatabase
test_file_name = "OgnIsEmptyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_IsEmpty")
database = OgnIsEmptyDatabase(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:isEmpty"))
attribute = test_node.get_attribute("outputs:isEmpty")
db_value = database.outputs.isEmpty
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCurveTubePositions.py | import os
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.nodes.ogn.OgnCurveTubePositionsDatabase import OgnCurveTubePositionsDatabase
test_file_name = "OgnCurveTubePositionsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CurveTubePositions")
database = OgnCurveTubePositionsDatabase(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("inputs:cols"))
attribute = test_node.get_attribute("inputs:cols")
db_value = database.inputs.cols
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curvePoints"))
attribute = test_node.get_attribute("inputs:curvePoints")
db_value = database.inputs.curvePoints
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexCounts"))
attribute = test_node.get_attribute("inputs:curveVertexCounts")
db_value = database.inputs.curveVertexCounts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexStarts"))
attribute = test_node.get_attribute("inputs:curveVertexStarts")
db_value = database.inputs.curveVertexStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:out"))
attribute = test_node.get_attribute("inputs:out")
db_value = database.inputs.out
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:tubePointStarts"))
attribute = test_node.get_attribute("inputs:tubePointStarts")
db_value = database.inputs.tubePointStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:up"))
attribute = test_node.get_attribute("inputs:up")
db_value = database.inputs.up
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:width"))
attribute = test_node.get_attribute("inputs:width")
db_value = database.inputs.width
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:points"))
attribute = test_node.get_attribute("outputs:points")
db_value = database.outputs.points
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineSet.py | import os
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.nodes.ogn.OgnTimelineSetDatabase import OgnTimelineSetDatabase
test_file_name = "OgnTimelineSetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetTimeline")
database = OgnTimelineSetDatabase(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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:propName"))
attribute = test_node.get_attribute("inputs:propName")
db_value = database.inputs.propName
expected_value = "Frame"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:propValue"))
attribute = test_node.get_attribute("inputs:propValue")
db_value = database.inputs.propValue
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:clamped"))
attribute = test_node.get_attribute("outputs:clamped")
db_value = database.outputs.clamped
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadTime.py | import os
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.nodes.ogn.OgnReadTimeDatabase import OgnReadTimeDatabase
test_file_name = "OgnReadTimeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadTime")
database = OgnReadTimeDatabase(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:absoluteSimTime"))
attribute = test_node.get_attribute("outputs:absoluteSimTime")
db_value = database.outputs.absoluteSimTime
self.assertTrue(test_node.get_attribute_exists("outputs:deltaSeconds"))
attribute = test_node.get_attribute("outputs:deltaSeconds")
db_value = database.outputs.deltaSeconds
self.assertTrue(test_node.get_attribute_exists("outputs:frame"))
attribute = test_node.get_attribute("outputs:frame")
db_value = database.outputs.frame
self.assertTrue(test_node.get_attribute_exists("outputs:isPlaying"))
attribute = test_node.get_attribute("outputs:isPlaying")
db_value = database.outputs.isPlaying
self.assertTrue(test_node.get_attribute_exists("outputs:time"))
attribute = test_node.get_attribute("outputs:time")
db_value = database.outputs.time
self.assertTrue(test_node.get_attribute_exists("outputs:timeSinceStart"))
attribute = test_node.get_attribute("outputs:timeSinceStart")
db_value = database.outputs.timeSinceStart
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAnd.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, False, True, True]}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True, False, True]}, False],
],
'outputs': [
['outputs:result', [False, False, False, True], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False],
],
'outputs': [
['outputs:result', [False, False], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:b', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', [False, False], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanAnd", "omni.graph.nodes.BooleanAnd", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanAnd User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanAnd","omni.graph.nodes.BooleanAnd", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanAnd User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BooleanAnd", "omni.graph.nodes.BooleanAnd", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BooleanAnd User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnAndDatabase import OgnAndDatabase
test_file_name = "OgnAndTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BooleanAnd")
database = OgnAndDatabase(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), 2)
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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayInsertValue.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:index', 0, False],
['inputs:value', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [1, 41, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [41, 1, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:index', 2, False],
['inputs:value', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [41, 42, 1]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOO', 'BAR']}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'token', 'value': 'BAZ'}, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['FOO', 'BAZ', 'BAR']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[]', 'value': [41, 42]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'half', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'half[]', 'value': [41, 1, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[41, 1], [42, 2]]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'half[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:array', {'type': 'half[2][]', 'value': [[41, 1], [1, 2], [42, 2]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[41, 1], [42, 2]]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:array', {'type': 'double[2][]', 'value': [[41, 1], [1, 2], [42, 2]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayInsertValue", "omni.graph.nodes.ArrayInsertValue", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayInsertValue User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayInsertValue","omni.graph.nodes.ArrayInsertValue", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayInsertValue User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayInsertValue", "omni.graph.nodes.ArrayInsertValue", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayInsertValue User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayInsertValueDatabase import OgnArrayInsertValueDatabase
test_file_name = "OgnArrayInsertValueTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayInsertValue")
database = OgnArrayInsertValueDatabase(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("inputs:index"))
attribute = test_node.get_attribute("inputs:index")
db_value = database.inputs.index
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMatrixMultiply.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'matrixd[3]', 'value': [1, 2, 3, 4, 5, 6, 7, 8, 9]}, False],
['inputs:b', {'type': 'matrixd[3]', 'value': [10, 11, 12, 13, 14, 15, 16, 17, 18]}, False],
],
'outputs': [
['outputs:output', {'type': 'matrixd[3]', 'value': [84, 90, 96, 201, 216, 231, 318, 342, 366]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'matrixd[4]', 'value': [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]}, False],
['inputs:b', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
],
'outputs': [
['outputs:output', {'type': 'matrixd[4]', 'value': [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
['inputs:b', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
'outputs': [
['outputs:output', {'type': 'double', 'value': 30}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
['inputs:b', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
['inputs:b', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MatrixMultiply", "omni.graph.nodes.MatrixMultiply", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MatrixMultiply User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MatrixMultiply","omni.graph.nodes.MatrixMultiply", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MatrixMultiply User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MatrixMultiply", "omni.graph.nodes.MatrixMultiply", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MatrixMultiply User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMatrixMultiplyDatabase import OgnMatrixMultiplyDatabase
test_file_name = "OgnMatrixMultiplyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MatrixMultiply")
database = OgnMatrixMultiplyDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantFloat4.py | import os
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.nodes.ogn.OgnConstantFloat4Database import OgnConstantFloat4Database
test_file_name = "OgnConstantFloat4Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantFloat4")
database = OgnConstantFloat4Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetGatheredAttribute.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
import os
class TestOgn(ogts.OmniGraphTestCase):
async def test_generated(self):
test_data = [{'inputs': [['inputs:name', '_translate', False]], 'outputs': [['outputs:value', {'type': 'pointd[3][]', 'value': [[1, 2, 3], [4, 5, 6]]}, False]], 'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.GetGatheredAttribute'], ['GatherByPath', 'omni.graph.nodes.GatherByPath']], 'create_prims': [['Empty', {}], ['Xform1', {'_translate': ['pointd[3]', [1, 2, 3]]}], ['Xform2', {'_translate': ['pointd[3]', [4, 5, 6]]}], ['XformTagged1', {'foo': ['token', ''], '_translate': ['pointd[3]', [1, 2, 3]]}], ['Tagged1', {'foo': ['token', '']}]], 'connect': [['GatherByPath.outputs:gatherId', 'TestNode.inputs:gatherId']], 'set_values': [['GatherByPath.inputs:primPaths', ['/Xform1', '/Xform2']], ['GatherByPath.inputs:attributes', '_translate'], ['GatherByPath.inputs:allAttributes', False]]}}]
test_node = None
test_graph = None
for i, test_run in enumerate(test_data):
inputs = test_run.get('inputs', [])
outputs = test_run.get('outputs', [])
state_set = test_run.get('state_set', [])
state_get = test_run.get('state_get', [])
setup = test_run.get('setup', None)
if setup is None or setup:
await omni.usd.get_context().new_stage_async()
test_graph = None
elif not setup:
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test is misconfigured - empty setup cannot be in the first test")
if setup:
(test_graph, test_nodes, _, _) = og.Controller.edit("/TestGraph", setup)
self.assertTrue(test_nodes)
test_node = test_nodes[0]
elif setup is None:
if test_graph is None:
test_graph = og.Controller.create_graph("/TestGraph")
self.assertTrue(test_graph is not None and test_graph.is_valid())
test_node = og.Controller.create_node(
("TestNode_omni_graph_nodes_GetGatheredAttribute", test_graph), "omni.graph.nodes.GetGatheredAttribute"
)
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test graph invalid")
self.assertTrue(test_node is not None and test_node.is_valid(), "Test node invalid")
await og.Controller.evaluate(test_graph)
values_to_set = inputs + state_set
if values_to_set:
for attribute_name, attribute_value, _ in inputs + state_set:
og.Controller((attribute_name, test_node)).set(attribute_value)
await og.Controller.evaluate(test_graph)
for attribute_name, expected_value, _ in outputs + state_get:
attribute = og.Controller.attribute(attribute_name, test_node)
actual_output = og.Controller.get(attribute)
expected_type = None
if isinstance(expected_value, dict):
expected_type = expected_value["type"]
expected_value = expected_value["value"]
ogts.verify_values(expected_value, actual_output, f"omni.graph.nodes.GetGatheredAttribute User test case #{i+1}: {attribute_name} attribute value error")
if expected_type:
tp = og.AttributeType.type_from_ogn_type_name(expected_type)
actual_type = attribute.get_resolved_type()
if tp != actual_type:
raise ValueError(f"omni.graph.nodes.GetGatheredAttribute User tests - {attribute_name}: Expected {expected_type}, saw {actual_type.get_ogn_type_name()}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetGatheredAttributeDatabase import OgnGetGatheredAttributeDatabase
test_file_name = "OgnGetGatheredAttributeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetGatheredAttribute")
database = OgnGetGatheredAttributeDatabase(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("inputs:gatherId"))
attribute = test_node.get_attribute("inputs:gatherId")
db_value = database.inputs.gatherId
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantFloat3.py | import os
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.nodes.ogn.OgnConstantFloat3Database import OgnConstantFloat3Database
test_file_name = "OgnConstantFloat3Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantFloat3")
database = OgnConstantFloat3Database(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnExtractBundle.py | import os
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.nodes.ogn.OgnExtractBundleDatabase import OgnExtractBundleDatabase
test_file_name = "OgnExtractBundleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ExtractBundle")
database = OgnExtractBundleDatabase(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), 3)
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("inputs:bundle"))
attribute = test_node.get_attribute("inputs:bundle")
db_value = database.inputs.bundle
self.assertTrue(test_node.get_attribute_exists("outputs_passThrough"))
attribute = test_node.get_attribute("outputs_passThrough")
db_value = database.outputs.passThrough
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToDeg.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:radians', {'type': 'double', 'value': -1.0}, False],
],
'outputs': [
['outputs:degrees', {'type': 'double', 'value': -57.2958}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToDeg", "omni.graph.nodes.ToDeg", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDeg User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToDeg","omni.graph.nodes.ToDeg", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDeg User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToDeg", "omni.graph.nodes.ToDeg", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToDeg User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToDegDatabase import OgnToDegDatabase
test_file_name = "OgnToDegTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToDeg")
database = OgnToDegDatabase(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"
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantHalf.py | import os
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.nodes.ogn.OgnConstantHalfDatabase import OgnConstantHalfDatabase
test_file_name = "OgnConstantHalfTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantHalf")
database = OgnConstantHalfDatabase(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("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnLengthAlongCurve.py | import os
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):
TEST_DATA = [
{
'inputs': [
['inputs:curveVertexStarts', [0], False],
['inputs:curveVertexCounts', [4], False],
['inputs:curvePoints', [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 4.0, 4.0], [12.0, 13.0, 4.0]], False],
['inputs:normalize', False, False],
],
'outputs': [
['outputs:length', [0.0, 1.0, 6.0, 21.0], False],
],
},
{
'inputs': [
['inputs:curveVertexStarts', [0], False],
['inputs:curveVertexCounts', [3], False],
['inputs:curvePoints', [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, 1.0]], False],
['inputs:normalize', True, False],
],
'outputs': [
['outputs:length', [0.0, 0.5, 1.0], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_LengthAlongCurve", "omni.graph.nodes.LengthAlongCurve", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.LengthAlongCurve User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_LengthAlongCurve","omni.graph.nodes.LengthAlongCurve", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.LengthAlongCurve User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_LengthAlongCurve", "omni.graph.nodes.LengthAlongCurve", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.LengthAlongCurve User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnLengthAlongCurveDatabase import OgnLengthAlongCurveDatabase
test_file_name = "OgnLengthAlongCurveTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_LengthAlongCurve")
database = OgnLengthAlongCurveDatabase(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("inputs:curvePoints"))
attribute = test_node.get_attribute("inputs:curvePoints")
db_value = database.inputs.curvePoints
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexCounts"))
attribute = test_node.get_attribute("inputs:curveVertexCounts")
db_value = database.inputs.curveVertexCounts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexStarts"))
attribute = test_node.get_attribute("inputs:curveVertexStarts")
db_value = database.inputs.curveVertexStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalize"))
attribute = test_node.get_attribute("inputs:normalize")
db_value = database.inputs.normalize
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:length"))
attribute = test_node.get_attribute("outputs:length")
db_value = database.outputs.length
|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetVariantSelection.py | import os
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.nodes.ogn.OgnSetVariantSelectionDatabase import OgnSetVariantSelectionDatabase
test_file_name = "OgnSetVariantSelectionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetVariantSelection")
database = OgnSetVariantSelectionDatabase(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), 2)
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("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:setVariant"))
attribute = test_node.get_attribute("inputs:setVariant")
db_value = database.inputs.setVariant
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantName"))
attribute = test_node.get_attribute("inputs:variantName")
db_value = database.inputs.variantName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantSetName"))
attribute = test_node.get_attribute("inputs:variantSetName")
db_value = database.inputs.variantSetName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.