Example #1
0
    def test___add__(self):
        s = Sequence(["file.01.ext"])
        ns = s + Item("file.02.ext")
        self.assertEqual(len(ns), 2)
        self.assertEqual(ns[0], s[0])
        self.assertEqual(ns[1], Item("file.02.ext"))
        self.assertEqual(len(s), 1)

        ns = s + "file.02.ext"
        self.assertEqual(len(ns), 2)
        self.assertEqual(ns[0], s[0])
        self.assertEqual(ns[1], Item("file.02.ext"))
        self.assertEqual(len(s), 1)

        ns = s + ["file.02.ext"]
        self.assertEqual(len(ns), 2)
        self.assertEqual(ns[0], s[0])
        self.assertEqual(ns[1], Item("file.02.ext"))
        self.assertEqual(len(s), 1)

        ns = s + Sequence(["file.02.ext"])
        self.assertEqual(len(ns), 2)
        self.assertEqual(ns[0], s[0])
        self.assertEqual(ns[1], Item("file.02.ext"))
        self.assertEqual(len(s), 1)

        self.assertRaises(SequenceError, s.__add__, "item.01.ext")
        self.assertRaises(TypeError, s.__add__, 1)
Example #2
0
    def test_insert(self):
        s = Sequence(["file.001.ext"])
        s.insert(0, "file.002.ext")
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], Item("file.002.ext"))
        self.assertEqual(s[1], Item("file.001.ext"))

        self.assertRaises(SequenceError, s.insert, 1, "item")
Example #3
0
    def test___setitem__(self):
        s = Sequence(["file.01.ext", "file.05.ext"])
        s[1] = "file.02.ext"
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], Item("file.01.ext"))
        self.assertEqual(s[1], Item("file.02.ext"))

        self.assertRaises(SequenceError, s.__setitem__, 0, "item.1.ext")
Example #4
0
    def test_is_sibling_method_is_working_properly(self):
        """testing if the is_sibling() is working properly
        """
        item1 = Item('/mnt/S/Some/Path/to/a/file/with/numbers/file.0010.exr')
        item2 = Item('/mnt/S/Some/Path/to/a/file/with/numbers/file.0101.exr')

        self.assertTrue(item1.is_sibling(item2))
        self.assertTrue(item2.is_sibling(item1))
Example #5
0
    def test_extend(self):
        s = Sequence(["file.001.ext"])
        s.extend(["file.002.ext", "file.003.ext"])
        self.assertEqual(len(s), 3)
        self.assertEqual(s[0], Item("file.001.ext"))
        self.assertEqual(s[1], Item("file.002.ext"))
        self.assertEqual(s[2], Item("file.003.ext"))

        self.assertRaises(SequenceError, s.extend, ["item"])
Example #6
0
    def test_dirname_attribute_is_read_only(self):
        """testing if the dirname attribute is read only
        """
        i = Item(self.test_path)
        with self.assertRaises(AttributeError) as cm:
            setattr(i, 'dirname', 'some value')

        self.assertEqual(str(cm.exception), "can't set attribute")
Example #7
0
 def test_name_attribute_is_working_properly(self):
     """testing if the name attribute is working properly
     """
     i = Item(self.test_path)
     self.assertEqual(
         i.name,
         'file.0010.exr'
     )
Example #8
0
 def test_path_attribute_is_working_properly(self):
     """testing if the path attribute is working properly
     """
     i = Item(self.test_path)
     self.assertEqual(
         self.test_path,
         i.path
     )
Example #9
0
 def test_parts_attribute_is_working_properly(self):
     """testing if the parts attribute is working properly
     """
     i = Item(self.test_path)
     self.assertEqual(
         i.parts,
         ['file.', '.exr']
     )
Example #10
0
 def test_digits_attribute_is_working_properly(self):
     """testing if the digits attribute is working properly
     """
     i = Item(self.test_path)
     self.assertEqual(
         i.digits,
         ['0010']
     )
Example #11
0
 def test_dirname_attribute_is_working_properly(self):
     """testing if the dirname attribute is working properly
     """
     
     i = Item(self.test_path)
     self.assertEqual(
         i.dirname,
         os.path.dirname(self.test_path)
     )
Example #12
0
    def test_is_sibling_method_is_working_properly(self):
        """testing if the is_sibling() is working properly
        """
        item1 = Item('/mnt/S/Some/Path/to/a/file/with/numbers/file.0010.exr')
        item2 = Item('/mnt/S/Some/Path/to/a/file/with/numbers/file.0101.exr')

        self.assertTrue(item1.is_sibling(item2))
        self.assertTrue(item2.is_sibling(item1))
Example #13
0
    def test___iadd__(self):
        s = Sequence(["file.01.ext"])
        s += Item("file.02.ext")
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], s[0])
        self.assertEqual(s[1], Item("file.02.ext"))

        s = Sequence(["file.01.ext"])
        s += "file.02.ext"
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], s[0])
        self.assertEqual(s[1], Item("file.02.ext"))

        s = Sequence(["file.01.ext"])
        s += ["file.02.ext"]
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], s[0])
        self.assertEqual(s[1], Item("file.02.ext"))

        s = Sequence(["file.01.ext"])
        s += Sequence(["file.02.ext"])
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], s[0])
        self.assertEqual(s[1], Item("file.02.ext"))
Example #14
0
 def test_dirname_attribute_is_working_properly(self):
     """testing if the dirname attribute is working properly
     """
     i = Item(self.test_path)
     self.assertEqual(i.dirname, '/mnt/S/Some/Path/to/a/file/with/numbers')
Example #15
0
 def test_initializing_with_a_string(self):
     """testing if initializing an Item with a string showing the path of a
     file is working properly
     """
     i = Item(self.test_path)
     self.assertTrue(isinstance(i, Item))
Example #16
0
    def test___setslice___(self):
        s = Sequence(["file.001.ext"])
        s[1:2] = "file.002.ext"
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], Item("file.001.ext"))
        self.assertEqual(s[1], Item("file.002.ext"))

        s = Sequence(["file.001.ext"])
        s[1:2] = Item("file.002.ext")
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], Item("file.001.ext"))
        self.assertEqual(s[1], Item("file.002.ext"))

        s = Sequence(["file.001.ext"])
        s[1:2] = [Item("file.002.ext")]
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], Item("file.001.ext"))
        self.assertEqual(s[1], Item("file.002.ext"))

        s = Sequence(["file.001.ext"])
        s[1:2] = Sequence([Item("file.002.ext")])
        self.assertEqual(len(s), 2)
        self.assertEqual(s[0], Item("file.001.ext"))
        self.assertEqual(s[1], Item("file.002.ext"))

        self.assertRaises(SequenceError, s.__setslice__, 1, 2, 'item.001.ext')