示例#1
0
    def test_is_optional(self):
        """
        testing the is_optional method
        """
        definition = "sequences/{Sequence}/{Shot}/{Step}/work/{Shot}[_{name}].v{version}.nk"
        template = tank.TemplatePath(definition, self.keys, self.project_root)

        self.assertTrue(template.is_optional("name"))
        self.assertFalse(template.is_optional("version"))
示例#2
0
 def test_optional_with_underscore(self):
     """
     Simulating error Ryan encountered whilst testing, where
     optional section containing name key starts with an underscore,
     and an underscore is present in the value of the preceding field.
     """
     definition = "sequences/{Sequence}/{Shot}/{Step}/work/{Shot}[_{name}].v{version}.nk"
     template = tank.TemplatePath(definition, self.keys, self.project_root)
     # leave out optional 'name' field
     relative_path = os.path.join("sequences", "seq_1", "shot_1", "Anm",
                                  "work", "shot_1.v001.nk")
     input_path = os.path.join(self.project_root, relative_path)
     expected = {
         "Sequence": "seq_1",
         "Shot": "shot_1",
         "Step": "Anm",
         "version": 1
     }
     result = template.get_fields(input_path)
     self.assertEqual(expected, result)
示例#3
0
 def test_no_keys_invalid(self):
     template = tank.TemplatePath("no/keys", {}, self.project_root)
     input_path = os.path.join(self.project_root, "some", "thing", "else")
     self.assertRaises(TankError, template.get_fields, input_path)
示例#4
0
 def test_no_keys_valid(self):
     template = tank.TemplatePath("no/keys", {}, self.project_root)
     input_path = os.path.join(self.project_root, "no/keys")
     self.assertEqual({}, template.get_fields(input_path))