Beispiel #1
0
 def test_version_attribute_is_set_to_none(self):
     """testing if setting the version attribute to None is possible
     """
     rep = Representation(self.version1)
     self.assertFalse(rep.version is None)
     rep.version = None
     self.assertTrue(rep.version is None)
Beispiel #2
0
 def test_find_method_finds_the_given_representation(self):
     """testing if Representation.find() finds the latest version with the
     given representation.
     """
     rep = Representation(self.version1)
     result = rep.find('BBox')
     self.assertEqual(self.version5, result)
Beispiel #3
0
 def test_find_method_finds_the_given_repr_from_different_repr(self):
     """testing if Representation.find() finds the latest version with the
     given representation from a different representation than the base one.
     """
     rep = Representation(self.version4)
     result = rep.find('ASS')
     self.assertEqual(self.version7, result)
Beispiel #4
0
 def test_find_method_finds_the_given_repr_from_different_repr(self):
     """testing if Representation.find() finds the latest version with the
     given representation from a different representation than the base one.
     """
     rep = Representation(self.version4)
     result = rep.find('ASS')
     self.assertEqual(self.version7, result)
Beispiel #5
0
 def test_version_attribute_is_set_to_none(self):
     """testing if setting the version attribute to None is possible
     """
     rep = Representation(self.version1)
     self.assertFalse(rep.version is None)
     rep.version = None
     self.assertTrue(rep.version is None)
Beispiel #6
0
 def test_find_method_finds_the_given_representation(self):
     """testing if Representation.find() finds the latest version with the
     given representation.
     """
     rep = Representation(self.version1)
     result = rep.find('BBox')
     self.assertEqual(self.version5, result)
Beispiel #7
0
 def test_version_attribute_is_working_properly(self):
     """testing if the version attribute is working properly
     """
     rep = Representation(self.version1)
     self.assertNotEqual(rep.version, self.version2)
     rep.version = self.version2
     self.assertEqual(rep.version, self.version2)
Beispiel #8
0
    def _validate_version(self, version):
        """validates the given version value

        :param version: A stalker.model.version.Version instance
        :return:
        """
        if not version:
            raise RuntimeError(
                'Please supply a valid Stalker Version object!'
            )

        from stalker import Version
        if not isinstance(version, Version):
            raise TypeError(
                'version should be a stalker.models.version.Version instance'
            )

        r = Representation(version=version)

        self.base_take_name = r.get_base_take_name(version)
        if not r.is_base():
            raise RuntimeError(
                'This is not a Base take for this representation series, '
                'please open the base (%s) take!!!' % self.base_take_name
            )

        return version
Beispiel #9
0
 def test_version_attribute_is_working_properly(self):
     """testing if the version attribute is working properly
     """
     rep = Representation(self.version1)
     self.assertNotEqual(rep.version, self.version2)
     rep.version = self.version2
     self.assertEqual(rep.version, self.version2)
Beispiel #10
0
 def test_list_all_lists_all_representations(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names.
     """
     expected_result = ['Base', 'BBox', 'ASS', 'GPU']
     rep = Representation(self.version1)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
Beispiel #11
0
 def test_list_all_lists_all_representations_from_non_base_version(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names by using non base version.
     """
     expected_result = ['Base', 'Hires', 'Midres', 'Lores']
     rep = Representation(self.version10)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
Beispiel #12
0
 def test_list_all_lists_all_representations_from_non_base_version(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names by using non base version.
     """
     expected_result = ['Base', 'Hires', 'Midres', 'Lores']
     rep = Representation(self.version10)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
Beispiel #13
0
 def test_list_all_lists_all_representations(self):
     """testing if Representation.list_all() returns a list of strings
     showing the repr names.
     """
     expected_result = ['Base', 'BBox', 'ASS', 'GPU']
     rep = Representation(self.version1)
     result = rep.list_all()
     self.assertEqual(sorted(expected_result), sorted(result))
Beispiel #14
0
    def test_is_base_method_is_working_properly(self):
        """testing if Representation.is_base() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.is_base())

        rep = Representation(self.version4)
        self.assertFalse(rep.is_base())
Beispiel #15
0
    def test_repr_property_is_working_properly(self):
        """testing if Representation.repr property is working properly
        """
        rep = Representation(self.version1)
        self.assertEqual(rep.repr, 'Base')

        rep = Representation(self.version4)
        self.assertTrue(rep.repr, 'BBox')
Beispiel #16
0
 def test_get_base_take_name_is_working_properly(self):
     """testing if the Representation.get_base_take_name() method is working
     properly
     """
     rep = Representation()
     self.assertEqual('Main', rep.get_base_take_name(self.version1))
     self.assertEqual('alt1', rep.get_base_take_name(self.version10))
     self.assertEqual('alt1', rep.get_base_take_name(self.version12))
     self.assertEqual('NoRepr', rep.get_base_take_name(self.version18))
Beispiel #17
0
def check_representations():
    """checks if the referenced versions are all matching the representation
    type of the current version
    """
    ref_reprs = []
    wrong_reprs = []

    v = staging.get('version')

    if v:
        r = Representation(version=v)
        current_repr = r.repr

        # For **Base** representation
        # allow any type of representation to be present in the scene
        if r.is_base():
            return

        for ref in pm.listReferences():
            ref_repr = ref.repr
            if ref_repr is None:
                # skip this one this is not related to a Stalker Version
                continue

            ref_reprs.append([ref, ref_repr])
            if ref_repr != current_repr:
                wrong_reprs.append(ref)
    else:
        return

    if len(wrong_reprs):
        ref_repr_labels = []
        for ref_repr in ref_reprs:
            ref = ref_repr[0]
            repr_name = ref_repr[1]

            color = 'red' if current_repr != repr_name else 'green'

            ref_repr_labels.append(
                '<span style="color: %(color)s">%(repr_name)s</span> -> '
                '%(ref)s' %
                {
                    'color': color,
                    'repr_name': repr_name,
                    'ref': ref.refNode.name()
                }
            )

        raise PublishError(
            'You are saving as the <b>%s</b> representation<br>'
            'for the current scene, but the following references<br>'
            'are not <b>%s</b> representations of their versions:<br><br>'
            '%s' % (
                current_repr, current_repr,
                '<br>'.join(ref_repr_labels[:MAX_NODE_DISPLAY])
            )
        )
Beispiel #18
0
 def test_get_base_take_name_is_working_properly(self):
     """testing if the Representation.get_base_take_name() method is working
     properly
     """
     rep = Representation()
     self.assertEqual('Main', rep.get_base_take_name(self.version1))
     self.assertEqual('alt1', rep.get_base_take_name(self.version10))
     self.assertEqual('alt1', rep.get_base_take_name(self.version12))
     self.assertEqual('NoRepr', rep.get_base_take_name(self.version18))
Beispiel #19
0
    def get_base(self):
        """returns the base version instance
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.find(rep.base_repr_name)
Beispiel #20
0
    def get_base(self):
        """returns the base version instance
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.find(rep.base_repr_name)
Beispiel #21
0
    def test_version_attribute_is_not_a_version_instance(self):
        """testing if a TypeError will be raised when the version attribute is
        set to a value other then None and a Version instance
        """
        rep = Representation()
        with self.assertRaises(TypeError) as cm:
            rep.version = 'not a version'

        self.assertEqual(
            'Representation.version should be a '
            'stalker.models.version.Version instance, not str',
            str(cm.exception))
Beispiel #22
0
def check_representations():
    """checks if the referenced versions are all matching the representation
    type of the current version
    """
    ref_reprs = []
    wrong_reprs = []

    v = staging.get('version')

    if v:
        r = Representation(version=v)
        current_repr = r.repr

        # For **Base** representation
        # allow any type of representation to be present in the scene
        if r.is_base():
            return

        for ref in pm.listReferences():
            ref_repr = ref.repr
            if ref_repr is None:
                # skip this one this is not related to a Stalker Version
                continue

            ref_reprs.append([ref, ref_repr])
            if ref_repr != current_repr:
                wrong_reprs.append(ref)
    else:
        return

    if len(wrong_reprs):
        ref_repr_labels = []
        for ref_repr in ref_reprs:
            ref = ref_repr[0]
            repr_name = ref_repr[1]

            color = 'red' if current_repr != repr_name else 'green'

            ref_repr_labels.append(
                '<span style="color: %(color)s">%(repr_name)s</span> -> '
                '%(ref)s' % {
                    'color': color,
                    'repr_name': repr_name,
                    'ref': ref.refNode.name()
                })

        raise PublishError(
            'You are saving as the <b>%s</b> representation<br>'
            'for the current scene, but the following references<br>'
            'are not <b>%s</b> representations of their versions:<br><br>'
            '%s' % (current_repr, current_repr, '<br>'.join(
                ref_repr_labels[:MAX_NODE_DISPLAY])))
Beispiel #23
0
    def test_version_attribute_is_not_a_version_instance(self):
        """testing if a TypeError will be raised when the version attribute is
        set to a value other then None and a Version instance
        """
        rep = Representation()
        with self.assertRaises(TypeError) as cm:
            rep.version = 'not a version'

        self.assertEqual(
            'Representation.version should be a '
            'stalker.models.version.Version instance, not str',
            str(cm.exception)
        )
Beispiel #24
0
    def is_base(self):
        """returns True or False depending to if this is the base
        representation for this reference
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.is_base()
Beispiel #25
0
    def is_base(self):
        """returns True or False depending to if this is the base
        representation for this reference
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return True

        rep = Representation(version=v)
        return rep.is_base()
Beispiel #26
0
    def test_is_repr_method_is_working_properly(self):
        """testing if Representation.is_repr() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.is_repr('Base'))

        rep = Representation(self.version4)
        self.assertFalse(rep.is_repr('Base'))

        rep = Representation(self.version4)
        self.assertTrue(rep.is_repr('BBox'))
Beispiel #27
0
    def is_repr(self, repr_name):
        """returns True or False depending to if this is the requested repr

        :param str repr_name: The representation name
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.is_repr(repr_name=repr_name)
Beispiel #28
0
    def list_all_repr(self):
        """Returns a list of strings representing all the representation names
        of this FileReference

        :return: list of str
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return []

        rep = Representation(version=v)
        return rep.list_all()
Beispiel #29
0
    def list_all_repr(self):
        """Returns a list of strings representing all the representation names
        of this FileReference

        :return: list of str
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return []

        rep = Representation(version=v)
        return rep.list_all()
Beispiel #30
0
    def has_repr(self, repr_name):
        """checks if the reference has the given representation

        :param str repr_name: The name of the desired representation
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.has_repr(repr_name)
Beispiel #31
0
    def is_repr(self, repr_name):
        """returns True or False depending to if this is the requested repr

        :param str repr_name: The representation name
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.is_repr(repr_name=repr_name)
Beispiel #32
0
    def has_repr(self, repr_name):
        """checks if the reference has the given representation

        :param str repr_name: The name of the desired representation
        :return:
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return False

        rep = Representation(version=v)
        return rep.has_repr(repr_name)
Beispiel #33
0
    def find_repr(self, repr_name):
        """Finds the representation with the given repr_name.

        :param str repr_name: The desired repr name
        :return: :class:`.Version`
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return

        rep = Representation(version=v)
        rep_v = rep.find(repr_name)

        return rep_v
Beispiel #34
0
    def find_repr(self, repr_name):
        """Finds the representation with the given repr_name.

        :param str repr_name: The desired repr name
        :return: :class:`.Version`
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return

        rep = Representation(version=v)
        rep_v = rep.find(repr_name)

        return rep_v
Beispiel #35
0
    def test_version_argument_is_not_a_version_instance(self):
        """testing if a TypeError will be raised when the version argument is
        not a Version instance
        """
        with self.assertRaises(TypeError) as cm:
            Representation('not a version')

        self.assertEqual(
            'Representation.version should be a '
            'stalker.models.version.Version instance, not str',
            str(cm.exception))
Beispiel #36
0
    def repr(self):
        """the representation name of the related version
        """
        from anima.env.mayaEnv import Maya
        m = Maya()
        v = m.get_version_from_full_path(self.path)

        if v is None:
            return None

        rep = Representation(version=v)
        return rep.repr
Beispiel #37
0
    def test_has_repr_method_is_working_properly(self):
        """testing if Representation.has_repr() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.has_repr('BBox'))

        rep.version = self.version17
        self.assertTrue(rep.has_repr('Lores'))

        rep.version = self.version19
        self.assertFalse(rep.has_repr('BBox'))
Beispiel #38
0
    def test_has_repr_method_is_working_properly(self):
        """testing if Representation.has_repr() method is working properly
        """
        rep = Representation(self.version1)
        self.assertTrue(rep.has_repr('BBox'))

        rep.version = self.version17
        self.assertTrue(rep.has_repr('Lores'))

        rep.version = self.version19
        self.assertFalse(rep.has_repr('BBox'))
Beispiel #39
0
 def test_version_argument_is_skipped(self):
     """testing if it is possible to skip the version argument
     """
     rep = Representation()
     self.assertTrue(rep.version is None)
Beispiel #40
0
 def test_find_method_returns_none_for_invalid_repr_name(self):
     """testing if Representation.find() returns None for invalid or
     nonexistent repr name
     """
     rep = Representation(self.version4)
     self.assertTrue(rep.find('NonExists') is None)
Beispiel #41
0
 def test_find_method_returns_none_for_invalid_repr_name(self):
     """testing if Representation.find() returns None for invalid or
     nonexistent repr name
     """
     rep = Representation(self.version4)
     self.assertTrue(rep.find('NonExists') is None)
Beispiel #42
0
 def test_version_argument_is_none(self):
     """testing if the version argument can be None
     """
     rep = Representation(None)
     self.assertTrue(rep.version is None)
Beispiel #43
0
 def test_version_argument_is_working_properly(self):
     """testing if the version argument value is correctly passed to the
     version attribute
     """
     rep = Representation(self.version1)
     self.assertEqual(rep.version, self.version1)