Пример #1
0
    def test_optional_sections(self):
        """
        Test that definition using optional sections resolves for missing optional values.
        """
        definition = "shots/{Sequence}/{Shot}/{Step}/work/{Shot}[.{branch}][.v{version}][.{snapshot}.ma]"
        template = TemplatePath(definition, self.keys, self.project_root)

        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1.mmm.v003.002.ma")
        input_path = os.path.join(self.project_root, relative_path)

        expected = {"Sequence": "seq_1",
                    "Shot": "s1",
                    "Step": "Anm",
                    "branch":"mmm",
                    "version": 3,
                    "snapshot": 2}

        result = template.get_fields(input_path)
        self.assertEqual(expected, result)

        # remove version value
        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1.mmm.002.ma")
        input_path = os.path.join(self.project_root, relative_path)

        expected = {"Sequence": "seq_1",
                    "Shot": "s1",
                    "Step": "Anm",
                    "branch":"mmm",
                    "snapshot": 2}

        result = template.get_fields(input_path)
        self.assertEqual(expected, result)

        # remove all optional values
        relative_path = os.path.join("shots",
                                     "seq_1",
                                     "s1",
                                     "Anm",
                                     "work",
                                     "s1")
        input_path = os.path.join(self.project_root, relative_path)

        expected = {"Sequence": "seq_1",
                    "Shot": "s1",
                    "Step": "Anm"}

        result = template.get_fields(input_path)
        self.assertEqual(expected, result)
Пример #2
0
 def test_valid_alphanumeric(self):
     """Bug reported in Ticket #17090"""
     template = TemplatePath("{branch}.v{version}.nk", self.keys, self.project_root)
     input_path = os.path.join(self.project_root, "comp.v001.nk")
     expected = {"branch": "comp",
                 "version": 1}
     result = template.get_fields(input_path)
     self.assertEquals(expected, result)
Пример #3
0
 def test_one_key(self):
     definition = "{Shot}/boo.wtf"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("shot_1", "boo.wtf")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Shot": "shot_1"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #4
0
 def test_key_first_short(self):
     definition =  "{Step}/{Shot}.png"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("Anm", "shot_1.png")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Step": "Anm",
                 "Shot": "shot_1"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #5
0
 def test_aliased_key(self):
     key = IntegerKey("aliased_name")
     keys = {"initial_name": key}
     definition = "{initial_name}"
     template = TemplatePath(definition, keys, self.project_root)
     input_path = os.path.join(self.project_root, "3")
     expected = {"aliased_name": 3}
     result = template.get_fields(input_path)
     self.assertEquals(expected, result)
Пример #6
0
 def test_key_at_end(self):
     definition = "sequences/{Sequence}/{Shot}/{Step}"
     template = TemplatePath(definition,
                             self.keys,
                             root_path=self.project_root)
     relative_path = "sequences/Seq1/Shot_1/Anm"
     input_path = os.path.join(self.project_root, relative_path)
     expected = {"Sequence": "Seq1", "Shot": "Shot_1", "Step": "Anm"}
     actual = template.get_fields(input_path)
     self.assertEquals(expected, actual)
Пример #7
0
 def test_one_key(self):
     definition = "{Shot}/boo.wtf"
     template = TemplatePath(definition,
                             self.keys,
                             root_path=self.project_root)
     relative_path = os.path.join("shot_1", "boo.wtf")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Shot": "shot_1"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #8
0
 def test_double_int_key(self):
     """Test case that key of type int appears twice in definition."""
     int_key = IntegerKey("int_key")
     definition = "{int_key}/something/{int_key}.else"
     template = TemplatePath(definition, {"int_key": int_key}, root_path=self.project_root)
     expected = {"int_key": 4}
     relative_path = "4/something/4.else"
     input_path = os.path.join(self.project_root, relative_path)
     actual = template.get_fields(input_path)
     self.assertEquals(expected, actual)
Пример #9
0
 def test_key_at_end(self):
     definition = "sequences/{Sequence}/{Shot}/{Step}"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = "sequences/Seq1/Shot_1/Anm"
     input_path = os.path.join(self.project_root, relative_path)
     expected = {"Sequence": "Seq1",
                 "Shot": "Shot_1",
                 "Step": "Anm"}
     actual = template.get_fields(input_path)
     self.assertEquals(expected, actual)
Пример #10
0
 def test_key_first_short(self):
     definition = "{Step}/{Shot}.png"
     template = TemplatePath(definition,
                             self.keys,
                             root_path=self.project_root)
     relative_path = os.path.join("Anm", "shot_1.png")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Step": "Anm", "Shot": "shot_1"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #11
0
 def test_double_int_key(self):
     """Test case that key of type int appears twice in definition."""
     int_key = IntegerKey("int_key")
     definition = "{int_key}/something/{int_key}.else"
     template = TemplatePath(definition, {"int_key": int_key},
                             root_path=self.project_root)
     expected = {"int_key": 4}
     relative_path = "4/something/4.else"
     input_path = os.path.join(self.project_root, relative_path)
     actual = template.get_fields(input_path)
     self.assertEquals(expected, actual)
Пример #12
0
 def test_diff_seperators(self):
     definition = "shots/{Sequence}/{Shot}/{Step}/work"
     template = TemplatePath(definition,
                             self.keys,
                             root_path=self.project_root)
     relative_path = os.path.join("shots", "seq_1", "shot_1", "Anm", "work")
     file_path = os.path.join(self.project_root, relative_path)
     # adding extra seperator to end
     file_path = file_path + os.path.sep
     expected = {"Sequence": "seq_1", "Shot": "shot_1", "Step": "Anm"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #13
0
 def test_diff_seperators(self):
     definition = "shots/{Sequence}/{Shot}/{Step}/work"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("shots", "seq_1", "shot_1", "Anm", "work")
     file_path = os.path.join(self.project_root, relative_path)
     # adding extra seperator to end
     file_path = file_path + os.path.sep
     expected = {"Sequence": "seq_1",
                 "Shot": "shot_1",
                 "Step": "Anm"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #14
0
 def test_key_first(self):
     definition = "{Sequence}/{Shot}/{Step}/work/{Shot}.{branch}.v{version}.{snapshot}.ma"
     template = TemplatePath(definition, self.keys, root_path=self.project_root)
     relative_path = os.path.join("seq_1",
                                  "shot_1",
                                  "Anm",
                                  "work",
                                  "shot_1.mmm.v003.002.ma")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {"Sequence": "seq_1",
                 "Shot": "shot_1",
                 "Step": "Anm",
                 "branch":"mmm",
                 "version": 3,
                 "snapshot": 2}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #15
0
 def test_key_first(self):
     definition = "{Sequence}/{Shot}/{Step}/work/{Shot}.{branch}.v{version}.{snapshot}.ma"
     template = TemplatePath(definition,
                             self.keys,
                             root_path=self.project_root)
     relative_path = os.path.join("seq_1", "shot_1", "Anm", "work",
                                  "shot_1.mmm.v003.002.ma")
     file_path = os.path.join(self.project_root, relative_path)
     expected = {
         "Sequence": "seq_1",
         "Shot": "shot_1",
         "Step": "Anm",
         "branch": "mmm",
         "version": 3,
         "snapshot": 2
     }
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #16
0
 def assert_path_matches(self, definition, input_path, expected):
     template = TemplatePath(definition, self.keys, "")
     result = template.get_fields(input_path)
     self.assertEquals(expected, result)
Пример #17
0
 def test_matching_enum(self):
     template = TemplatePath("{Shot}", self.keys, root_path=self.project_root)
     file_path = os.path.join(self.project_root, "s2")
     expected = {"Shot": "s2"}
     result = template.get_fields(file_path)
     self.assertEquals(result, expected)
Пример #18
0
 def assert_path_matches(self, definition, input_path, expected):
     template = TemplatePath(definition, self.keys, "")
     result = template.get_fields(input_path)
     self.assertEquals(expected, result)