Skip to content

Commit 5216c2a

Browse files
authored
Implement unit tests for the "CSV" mapping files. (#43)
Signed-off-by: Thomas Mansencal <thomas.mansencal@gmail.com>
1 parent d588eac commit 5216c2a

File tree

4 files changed

+129
-0
lines changed

4 files changed

+129
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
"""
4+
Defines the unit tests for the
5+
:mod:`opencolorio_config_aces.config.cg.generate` module resources.
6+
"""
7+
8+
9+
import unittest
10+
import urllib.request
11+
12+
from pathlib import Path
13+
14+
__author__ = "OpenColorIO Contributors"
15+
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
16+
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
17+
__maintainer__ = "OpenColorIO Contributors"
18+
__email__ = "ocio-dev@lists.aswf.io"
19+
__status__ = "Production"
20+
21+
__all__ = [
22+
"TestConfigResources",
23+
]
24+
25+
26+
class TestConfigResources(unittest.TestCase):
27+
"""
28+
Define the *ACES* Computer Graphics (CG) *OpenColorIO* config resources
29+
unit tests methods.
30+
"""
31+
32+
def test_csv_mapping_file(self):
33+
"""Test the *CSV* mapping file."""
34+
35+
csv_local_path = (
36+
Path(__file__).parents[0]
37+
/ ".."
38+
/ "resources"
39+
/ "OpenColorIO-Config-ACES _CG_ Transforms - CG Config - Mapping.csv"
40+
)
41+
42+
with open(str(csv_local_path)) as csv_local_file:
43+
csv_local_content = csv_local_file.read()
44+
45+
csv_remote_url = (
46+
"https://docs.google.com/spreadsheets/d/"
47+
"1DqxmtZpnhL_9N1wayvcW0y3bZoHRom7A1c58YLlr89g/"
48+
"export?format=csv&gid=609660164"
49+
)
50+
51+
csv_remote_content = (
52+
urllib.request.urlopen(csv_remote_url).read().decode("utf-8")
53+
)
54+
55+
self.assertMultiLineEqual(
56+
"\n".join(csv_remote_content.splitlines()),
57+
"\n".join(csv_local_content.splitlines()),
58+
)
59+
60+
61+
if __name__ == "__main__":
62+
unittest.main()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
"""
4+
Defines the unit tests for the
5+
:mod:`opencolorio_config_aces.config.reference.generate` module resources.
6+
"""
7+
8+
9+
import unittest
10+
import urllib.request
11+
12+
from pathlib import Path
13+
14+
__author__ = "OpenColorIO Contributors"
15+
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
16+
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
17+
__maintainer__ = "OpenColorIO Contributors"
18+
__email__ = "ocio-dev@lists.aswf.io"
19+
__status__ = "Production"
20+
21+
__all__ = [
22+
"TestConfigResources",
23+
]
24+
25+
26+
class TestConfigResources(unittest.TestCase):
27+
"""
28+
Define the *aces-dev* reference *OpenColorIO* config resources unit tests
29+
methods.
30+
"""
31+
32+
def test_csv_mapping_file(self):
33+
"""Test the *CSV* mapping file."""
34+
35+
csv_local_path = (
36+
Path(__file__).parents[0]
37+
/ ".."
38+
/ "resources"
39+
/ "OpenColorIO-Config-ACES _Reference_ Transforms - "
40+
"Reference Config - Mapping.csv"
41+
)
42+
43+
with open(str(csv_local_path)) as csv_local_file:
44+
csv_local_content = csv_local_file.read()
45+
46+
csv_remote_url = (
47+
"https://docs.google.com/spreadsheets/d/"
48+
"1SXPt-USy3HlV2G2qAvh9zit6ZCINDOlfKT07yXJdWLg/"
49+
"export?format=csv&gid=273921464"
50+
)
51+
52+
csv_remote_content = (
53+
urllib.request.urlopen(csv_remote_url).read().decode("utf-8")
54+
)
55+
56+
self.assertMultiLineEqual(
57+
"\n".join(csv_remote_content.splitlines()),
58+
"\n".join(csv_local_content.splitlines()),
59+
)
60+
61+
62+
if __name__ == "__main__":
63+
unittest.main()

0 commit comments

Comments
 (0)