X-Git-Url: http://users.mur.at/ms/git/gitweb/?a=blobdiff_plain;f=aces_1.0.0%2Fpython%2Faces_ocio%2Ftests%2Ftests_aces_config.py;h=a451379e415729f055d7f521b91e399247a1a9af;hb=529f7b361204176430ea0df642e4ec00a5c54ad7;hp=4a6ea5c2432845d57b44d10854cacbc3dac5f6b1;hpb=81ebbcda56c215801a15a690b6f9949f25b04caf;p=OpenColorIO-Configs.git diff --git a/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py b/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py index 4a6ea5c..a451379 100644 --- a/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py +++ b/aces_1.0.0/python/aces_ocio/tests/tests_aces_config.py @@ -2,27 +2,33 @@ # -*- coding: utf-8 -*- """ -Defines unit tests for the generated *ACES* configuration. +Defines unit tests for *ACES* configuration. """ +from __future__ import division + import hashlib import os import re import shutil +import sys import tempfile import unittest -from aces_ocio.util import files_walker -from aces_ocio.create_aces_config import ( +sys.path.append(os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..'))) + +from aces_ocio.utilities import files_walker +from aces_ocio.config import ( ACES_OCIO_CTL_DIRECTORY_ENVIRON, - createACESConfig) + generate_config) -__author__ = '' -__copyright__ = '' +__author__ = 'ACES Developers' +__copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers' __license__ = '' -__maintainer__ = '' -__email__ = '' -__status__ = '' +__maintainer__ = 'ACES Developers' +__email__ = 'aces@oscars.org' +__status__ = 'Production' __all__ = ['REFERENCE_CONFIG_ROOT_DIRECTORY', 'HASH_TEST_PATTERNS', @@ -32,8 +38,8 @@ __all__ = ['REFERENCE_CONFIG_ROOT_DIRECTORY', # TODO: Investigate how the current config has been generated to use it for # tests. -# REFERENCE_CONFIG_ROOT_DIRECTORY = os.path.abspath( -# os.path.join(os.path.dirname(__file__), '..', '..')) +REFERENCE_CONFIG_ROOT_DIRECTORY = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..', '..')) REFERENCE_CONFIG_ROOT_DIRECTORY = '/colour-science/colour-ramblings/ocio/aces' HASH_TEST_PATTERNS = ('\.3dl', '\.lut', '\.csp') @@ -42,6 +48,7 @@ UNHASHABLE_TEST_PATTERNS = ('\.icc', '\.ocio') class TestACESConfig(unittest.TestCase): """ + Performs tests on the *ACES* configuration. """ def setUp(self): @@ -71,26 +78,49 @@ class TestACESConfig(unittest.TestCase): shutil.rmtree(self.__temporary_directory) @staticmethod - def directory_hashes(directory, filters_in=None, filters_out=None): + def directory_hashes(directory, + filters_in=None, + filters_out=None, + flags=0): """ + Recursively computes the hashes from the file within given directory. + + Parameters + ---------- + directory : str or unicode + Directory to compute the file hashes. + filters_in : array_like + Included patterns. + filters_out : array_like + Excluded patterns. + flags : int + Regex flags. + + Returns + ------- + dict + Directory file hashes. """ hashes = {} for path in files_walker(directory, filters_in=filters_in, - filters_out=filters_out): + filters_out=filters_out, + flags=flags): with open(path) as file: - hash = hashlib.md5( + digest = hashlib.md5( re.sub('\s', '', file.read())).hexdigest() - hashes[path.replace(directory, '')] = hash + hashes[path.replace(directory, '')] = digest return hashes def test_ACES_config(self): """ + Performs tests on the *ACES* configuration by computing hashes on the + generated configuration and comparing them to the existing one. """ - self.assertTrue(createACESConfig(self.__aces_ocio_ctl_directory, - self.__temporary_directory)) + self.assertTrue(generate_config(self.__aces_ocio_ctl_directory, + self.__temporary_directory)) reference_hashes = self.directory_hashes( REFERENCE_CONFIG_ROOT_DIRECTORY,