Пример #1
0
    def test_extend_contains(self):
        """Test extends path in a path container
        """
        container = Paths()
        self.assertEqual(
            container.as_list(),
            [])
        self.assertEqual(
            container.as_list(True),
            [])

        container.extend(
            ['/document', '/storage/data', '/storage'],
            verify=False)
        self.assertEqual(
            container.as_list(),
            ['/document',
             '/storage',
             '/storage/data'])
        self.assertEqual(
            container.as_list(True),
            ['/document',
             '/storage'])
Пример #2
0
    def test_update(self):
        """Test update a path in a container with a new one
        """
        container = Paths()
        container.extend(
            ['/document', '/storage/data', '/storage', '/goinfre/files'],
            verify=False)

        self.assertFalse(container.rename('/storage/missing', '/test/failure'))
        self.assertEqual(
            container.as_list(),
            ['/document',
             '/goinfre/files',
             '/storage',
             '/storage/data'])

        self.assertFalse(container.rename('/missing', '/failure'))
        self.assertEqual(
            container.as_list(),
            ['/document',
             '/goinfre/files',
             '/storage',
             '/storage/data'])

        self.assertFalse(container.rename('/goinfre', '/failure'))
        self.assertEqual(
            container.as_list(),
            ['/document',
             '/goinfre/files',
             '/storage',
             '/storage/data'])

        self.assertTrue(container.rename('/document', '/configuration'))
        self.assertEqual(
            container.as_list(),
            ['/configuration',
             '/goinfre/files',
             '/storage',
             '/storage/data'])

        self.assertTrue(container.rename('/goinfre/files', '/goinfre/logs'))
        self.assertEqual(
            container.as_list(),
            ['/configuration',
             '/goinfre/logs',
             '/storage',
             '/storage/data'])

        self.assertTrue(container.rename('/goinfre/logs', '/www/logs'))
        self.assertEqual(
            container.as_list(),
            ['/configuration',
             '/storage',
             '/storage/data',
             '/www/logs'])

        self.assertTrue(container.rename('/www/logs', '/storage/logs'))
        self.assertEqual(
            container.as_list(),
            ['/configuration',
             '/storage',
             '/storage/data',
             '/storage/logs'])