forked from StanfordVL/OmniGibson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_object_removal.py
79 lines (61 loc) · 1.81 KB
/
test_object_removal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import pytest
from utils import og_test
import omnigibson as og
from omnigibson.objects import DatasetObject
from omnigibson.utils.python_utils import NAMES
@og_test
def test_removal_and_readdition(env):
# Add an apple
apple = DatasetObject(
name="apple_unique",
category="apple",
model="agveuv",
)
# Import it into the scene
env.scene.add_object(apple)
# Check that apple exists
assert env.scene.object_registry("name", "apple_unique") is not None
# Step a few times
for _ in range(5):
og.sim.step()
# Remove the apple
env.scene.remove_object(obj=apple)
# Check that NAMES is the same as before
assert env.scene.object_registry("name", "apple_unique") is None
# Importing should work now
apple2 = DatasetObject(
name="apple_unique",
category="apple",
model="agveuv",
)
env.scene.add_object(apple2)
og.sim.step()
# Clear the stuff we added
env.scene.remove_object(apple2)
@og_test
def test_readdition(env):
# Add an apple
apple = DatasetObject(
name="apple_unique",
category="apple",
model="agveuv",
)
# Import it into the scene
env.scene.add_object(apple)
# Check that apple exists
assert env.scene.object_registry("name", "apple_unique") is not None
# Step a few times
for _ in range(5):
og.sim.step()
# Creating and importing a new apple should fail
with pytest.raises(AssertionError):
apple2 = DatasetObject(
name="apple_unique",
category="apple",
model="agveuv",
)
env.scene.add_object(apple2)
# Check that apple exists
assert env.scene.object_registry("name", "apple_unique") is not None
# Clear the stuff we added
env.scene.remove_object(apple)