forked from robot-descriptions/robot_descriptions.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_descriptions.py
More file actions
65 lines (57 loc) · 2.37 KB
/
test_descriptions.py
File metadata and controls
65 lines (57 loc) · 2.37 KB
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 Stéphane Caron
import os
import sys
import unittest
from importlib import import_module # type: ignore
import git
from robot_descriptions._descriptions import DESCRIPTIONS
from robot_descriptions._xacro import get_urdf_path
class TestDescriptions(unittest.TestCase):
"""Test fixture for all robot descriptions."""
def test_descriptions_are_sorted(self):
self.assertEqual(list(DESCRIPTIONS), sorted(DESCRIPTIONS))
def test_all_descriptions(self):
"""Check all robot-description submodules."""
for name, desc in DESCRIPTIONS.items():
description = import_module(f"robot_descriptions.{name}")
self.assertTrue(
os.path.exists(description.REPOSITORY_PATH),
f"Path {description.REPOSITORY_PATH} "
f"does not exist in {description}",
)
self.assertTrue(
os.path.exists(description.PACKAGE_PATH),
f"Path {description.PACKAGE_PATH} "
f"does not exist in {description}",
)
if desc.has_mjcf:
self.assertTrue(hasattr(description, "MJCF_PATH"))
self.assertTrue(
os.path.exists(description.MJCF_PATH),
f"MJCF path {description.MJCF_PATH} does not exist "
f"in {description}",
)
if desc.has_urdf:
self.assertTrue(
hasattr(description, "URDF_PATH")
or hasattr(description, "XACRO_PATH")
)
urdf_path = get_urdf_path(description)
self.assertTrue(
os.path.exists(urdf_path),
f"URDF path {urdf_path} does not exist "
f"in {description}",
)
def test_invalid_description_commit(self):
invalid_commit = "foobar"
os.environ["ROBOT_DESCRIPTION_COMMIT"] = invalid_commit
self.assertEqual(os.getenv("ROBOT_DESCRIPTION_COMMIT"), invalid_commit)
description_name = "robot_descriptions.sigmaban_description"
with self.assertRaises(git.exc.GitCommandError):
if description_name in sys.modules:
del sys.modules[description_name]
import_module(description_name)