Add a test for type attribute.

PiperOrigin-RevId: 649635359
Change-Id: Ibe5d9fcb5f14371e5f154d645b838a9d012331d5
This commit is contained in:
Yuval Tassa
2024-07-05 06:15:40 -07:00
committed by Copybara-Service
parent c6fd002f87
commit 9d0812911c
+3 -2
View File
@@ -62,8 +62,10 @@ class SpecsTest(absltest.TestCase):
# Add a site to the body with user data and read it back. # Add a site to the body with user data and read it back.
site = body.add_site() site = body.add_site()
site.name = 'sitename' site.name = 'sitename'
site.type = mujoco.mjtGeom.mjGEOM_BOX
site.userdata = [1, 2, 3, 4, 5, 6] site.userdata = [1, 2, 3, 4, 5, 6]
self.assertEqual(site.name, 'sitename') self.assertEqual(site.name, 'sitename')
self.assertEqual(site.type, mujoco.mjtGeom.mjGEOM_BOX)
np.testing.assert_array_equal(site.userdata, [1, 2, 3, 4, 5, 6]) np.testing.assert_array_equal(site.userdata, [1, 2, 3, 4, 5, 6])
# Check that the site and body have no id before compilation. # Check that the site and body have no id before compilation.
@@ -90,7 +92,7 @@ class SpecsTest(absltest.TestCase):
<worldbody> <worldbody>
<body name="baz" pos="1 2 3" quat="0 1 0 0"> <body name="baz" pos="1 2 3" quat="0 1 0 0">
<site name="sitename" pos="0 0 0" user="1 2 3 4 5 6"/> <site name="sitename" pos="0 0 0" type="box" user="1 2 3 4 5 6"/>
</body> </body>
</worldbody> </worldbody>
</mujoco> </mujoco>
@@ -232,6 +234,5 @@ class SpecsTest(absltest.TestCase):
self.assertEqual(spec.sensors[1].name, 'sensor2') self.assertEqual(spec.sensors[1].name, 'sensor2')
self.assertEqual(spec.sensors[2].name, 'sensor3') self.assertEqual(spec.sensors[2].name, 'sensor3')
if __name__ == '__main__': if __name__ == '__main__':
absltest.main() absltest.main()