Ejemplo n.º 1
0
    def test_inherit_existing(self):
        """Inherit from existing entry

        /root (height=50)
            /group (height=100)
                /subgroup <-- Inherits above

        """

        group = os.path.join(self.root_path, 'group')
        subgroup = os.path.join(group, 'subgroup')
        os.makedirs(subgroup)

        base_location = self.root
        group_location = om.Location(group)
        subgroup_location = om.Location(subgroup)

        base_value = om.Entry('height', value=50, parent=base_location)
        group_value = om.Entry('height', value=100, parent=group_location)
        om.flush(base_value)
        om.flush(group_value)

        # Get metadata from location where metadata doesn't exist
        height = om.Entry('height', parent=subgroup_location)
        om.inherit(height)

        self.assertEquals(height.value, 100)
Ejemplo n.º 2
0
    def test_inherit(self):
        """Inherit property from parenthood

        /projects
            /spiderman      (apps/maya/name)
                /1000       (apps/maya/name)
                    /cache  (no metadata)

        """

        shot_path = os.path.join(self.project_path, '1000', 'cache')
        shot_entry = om.entry(shot_path, 'apps/maya/name')
        om.inherit(shot_entry)
        self.assertEquals(shot_entry.value, 'Maya 2015 Shot 1000')
Ejemplo n.º 3
0
    address = location['address']
    om.pull(address)

    try:
        postcode = address['street']
    except KeyError:
        print "This is supposed to happen"

    # That won't work, since `street` isn't in level2,
    # but in level1. Let's try doing that again, but
    # this time, we will inherit data from parents of
    # level2.

    location = om.Location(level2)
    om.pull(location)

    address = location['address']
    om.inherit(address)  # <-- We will inherit, rather than pull

    try:
        postcode = address['street']
        print "Success"
    except KeyError:
        print "This is NOT supposed to happen"

except:
    raise

finally:
    shutil.rmtree(root)
Ejemplo n.º 4
0
 def test_inherit_nonexisting(self):
     child_path = os.path.join(self.project_path, '1000')
     child_entry = om.entry(child_path, 'apps/maya/notexist')
     om.inherit(child_entry)
     self.assertEquals(child_entry.value, None)
Ejemplo n.º 5
0
 def test_inherit(self):
     """Inherit"""
     child_path = os.path.join(self.project_path, '1000')
     child_entry = om.entry(child_path, 'apps/maya/version')
     om.inherit(child_entry)
     self.assertEquals(child_entry.value, 2015)