Exemplo n.º 1
0
 def test_key_only(self):
     definition = "{Shot}"
     template_string = TemplateString(definition, self.keys)
     input_string = "shot_1"
     expected = {"Shot": "shot_1"}
     result = template_string.get_fields(input_string)
     self.assertEquals(expected, result)
Exemplo n.º 2
0
 def test_key_only(self):
     definition = "{Shot}"
     template_string = TemplateString(definition, self.keys)
     input_string = "shot_1"
     expected = {"Shot": "shot_1"}
     result = template_string.get_fields(input_string)
     self.assertEqual(expected, result)
Exemplo n.º 3
0
 def test_key_first(self):
     definition = "{Shot}.{Sequence}"
     template_string = TemplateString(definition, self.keys)
     input_string = "shot_1.Seq_12"
     expected = {"Shot": "shot_1", "Sequence": "Seq_12"}
     result = template_string.get_fields(input_string)
     self.assertEqual(expected, result)
Exemplo n.º 4
0
 def test_key_first(self):
     definition = "{Shot}.{Sequence}"
     template_string = TemplateString(definition, self.keys)
     input_string = "shot_1.Seq_12"
     expected = {"Shot": "shot_1",
                 "Sequence": "Seq_12"}
     result = template_string.get_fields(input_string)
     self.assertEquals(expected, result)
Exemplo n.º 5
0
    def test_optional_value(self):
        template_string = TemplateString("something-{Shot}[.{Sequence}]", self.keys)
        fields = {"Shot": "shot_1",
                  "Sequence": "seq_2"}
        expected = "something-shot_1.seq_2"
        result = template_string.apply_fields(fields)
        self.assertEquals(expected, result)

        # remove optional value
        del(fields["Sequence"])
        expected = "something-shot_1"
        result = template_string.apply_fields(fields)
        self.assertEquals(expected, result)
Exemplo n.º 6
0
    def test_optional_value(self):
        template_string = TemplateString("something-{Shot}[.{Sequence}]",
                                         self.keys)
        fields = {"Shot": "shot_1", "Sequence": "seq_2"}
        expected = "something-shot_1.seq_2"
        result = template_string.apply_fields(fields)
        self.assertEqual(expected, result)

        # remove optional value
        del fields["Sequence"]
        expected = "something-shot_1"
        result = template_string.apply_fields(fields)
        self.assertEqual(expected, result)
Exemplo n.º 7
0
    def test_optional_values(self):
        template_string = TemplateString("something-{Shot}[.{Sequence}]",
                                         self.keys)

        input_string = "something-shot_1.seq_2"
        expected = {"Shot": "shot_1", "Sequence": "seq_2"}

        self.assertTrue(template_string.validate(input_string))

        # without optional value
        input_string = "something-shot_1"
        expected = {"Shot": "shot_1"}

        self.assertTrue(template_string.validate(input_string))
Exemplo n.º 8
0
    def test_optional_values(self):
        template_string = TemplateString("something-{Shot}[.{Sequence}]", self.keys)

        input_string = "something-shot_1.seq_2"
        expected = {"Shot": "shot_1",
                    "Sequence": "seq_2"}

        self.assertTrue(template_string.validate(input_string))


        # without optional value
        input_string = "something-shot_1"
        expected = {"Shot": "shot_1"}

        self.assertTrue(template_string.validate(input_string))
Exemplo n.º 9
0
 def test_static_key_first(self):
     definition = "{Shot}something-{Sequence}."
     template = TemplateString(definition, self.keys)
     expected = [[
         "%s%s" % (template._prefix, os.path.sep), "something-", "."
     ]]
     self.assertEqual(expected, template._static_tokens)
Exemplo n.º 10
0
 def test_definition_short_end_static(self):
     """Tests case when input string longer than definition which
     ends with non key."""
     definition = "{Shot}.something"
     template_string = TemplateString(definition, self.keys)
     input_string = "shot_1.something-else"
     self.assertRaises(TankError, self.template_string.get_fields,
                       input_string)
Exemplo n.º 11
0
 def setUp(self):
     super(TestTemplateString, self).setUp()
     self.keys = {
         "Sequence": StringKey("Sequence"),
         "Shot": StringKey("Shot"),
         "version": IntegerKey("version"),
     }
     self.template_string = TemplateString("something-{Shot}.{Sequence}",
                                           self.keys)
Exemplo n.º 12
0
 def test_definition_preseves_leading_slash(self):
     """
     The TemplateString should not change the use of os seperators in the
     input definition.
     """
     # forward slashes with leading slash
     definition = "/tmp/{Shot}/something/{Sequence}/"
     template_string = TemplateString(definition, self.keys)
     self.assertEqual(definition, template_string.definition)
Exemplo n.º 13
0
    def test_optional_values(self):
        """
        Test definition containing optional sections resolves correctly.
        """
        template_string = TemplateString("something-{Shot}[.{Sequence}]",
                                         self.keys)

        input_string = "something-shot_1.seq_2"
        expected = {"Shot": "shot_1", "Sequence": "seq_2"}

        result = template_string.get_fields(input_string)
        self.assertEqual(expected, result)

        # without optional value
        input_string = "something-shot_1"
        expected = {"Shot": "shot_1"}

        result = template_string.get_fields(input_string)
        self.assertEqual(expected, result)
Exemplo n.º 14
0
    def test_optional_values(self):
        """
        Test definition containing optional sections resolves correctly.
        """
        template_string = TemplateString("something-{Shot}[.{Sequence}]", self.keys)

        input_string = "something-shot_1.seq_2"
        expected = {"Shot": "shot_1",
                    "Sequence": "seq_2"}

        result = template_string.get_fields(input_string)
        self.assertEquals(expected, result)


        # without optional value
        input_string = "something-shot_1"
        expected = {"Shot": "shot_1"}

        result = template_string.get_fields(input_string)
        self.assertEquals(expected, result)
Exemplo n.º 15
0
 def test_key_first(self):
     definition = "{Shot}something-{Sequence}."
     template_string = TemplateString(definition, self.keys)
     valid_string = "shot_1something-Seq_12."
     self.assertTrue(template_string.validate(valid_string))
Exemplo n.º 16
0
 def test_key_first(self):
     definition = "{Shot}something-{Sequence}."
     template_string = TemplateString(definition, self.keys)
     valid_string = "shot_1something-Seq_12."
     self.assertTrue(template_string.validate(valid_string))
Exemplo n.º 17
0
 def test_conflicting_values(self):
     definition = "{Shot}-{Sequence}.{Shot}"
     template_string = TemplateString(definition, self.keys)
     invalid_string = "shot_1-Seq_12.shot_2"
     self.assertFalse(self.template_string.validate(invalid_string))
Exemplo n.º 18
0
 def test_definition_preserves_back_slashes(self):
     # back slashes with leading slash
     definition = r"\something\{Shot}\\"
     template_string = TemplateString(definition, self.keys)
     self.assertEqual(definition, template_string.definition)
Exemplo n.º 19
0
 def test_static_simple(self):
     definition = "something-{Shot}.{Sequence}"
     template = TemplateString(definition, self.keys)
     expected = [["%s%ssomething-" % (template._prefix, os.path.sep), "."]]
     self.assertEquals(expected, template._static_tokens)