Пример #1
0
 def setUp(self):
     test_map = ContainerMap('test_map',
                             initial=TEST_MAP_DATA,
                             check_integrity=False)
     self.f_res = ContainerDependencyResolver(test_map)
     self.r_res = ContainerDependencyResolver()
     self.r_res.update_backward(test_map)
class ContainerDependencyTest(unittest.TestCase):
    def setUp(self):
        test_map = ContainerMap('test_map', initial=TEST_MAP_DATA, check_integrity=False)
        dependency_items = list(test_map.dependency_items())
        self.f_res = ContainerDependencyResolver(dependency_items)
        self.r_res = ContainerDependentsResolver(dependency_items)

    def assertOrder(self, dependency_list, *items):
        iterator = iter(items)
        last_item = six.next(iterator)
        last_idx = dependency_list.index(last_item)
        for item in iterator:
            index = dependency_list.index(item)
            if index < last_idx:
                self.fail("{0} found before {1}, should be later.".format(item, last_item))

    def test_forward_resolution_order(self):
        a_dep = self.f_res.get_dependencies((ItemType.CONTAINER, 'test_map', 'a', None))
        self.assertOrder(a_dep,
                         (ItemType.VOLUME, 'test_map', 'd', 'dv'),
                         (ItemType.CONTAINER, 'test_map', 'd', '1'),
                         (ItemType.CONTAINER, 'test_map', 'd', '2'),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        self.assertOrder(a_dep,
                         (ItemType.CONTAINER, 'test_map', 'e', '1'),
                         (ItemType.CONTAINER, 'test_map', 'e', '2'),
                         (ItemType.CONTAINER, 'test_map', 'd', '1'),
                         (ItemType.CONTAINER, 'test_map', 'd', '2'))
        self.assertOrder(a_dep,
                         (ItemType.CONTAINER, 'test_map', 'e', '1'),
                         (ItemType.CONTAINER, 'test_map', 'e', '2'),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        self.assertOrder(a_dep,
                         (ItemType.CONTAINER, 'test_map', 'f', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        l_dep = self.f_res.get_dependencies((ItemType.CONTAINER, 'test_map', 'l', None))
        self.assertListEqual(l_dep, [
            (ItemType.IMAGE, 'test_map', 'e', 'latest'),
            (ItemType.CONTAINER, 'test_map', 'e', '1'),
            (ItemType.IMAGE, 'test_map', 'l', 'latest'),
        ])
        x_dep = self.f_res.get_dependencies((ItemType.CONTAINER, 'test_map', 'x', None))
        self.assertOrder(x_dep,
                         (ItemType.CONTAINER, 'test_map', 'f', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))

    def test_backward_resolution_order(self):
        f_dep = self.r_res.get_dependencies((ItemType.CONTAINER, 'test_map', 'f', None))
        self.assertOrder(f_dep,
                         (ItemType.CONTAINER, 'test_map', 'x', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        self.assertOrder(f_dep,
                         (ItemType.CONTAINER, 'test_map', 'a', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        e_dep = self.r_res.get_dependencies((ItemType.CONTAINER, 'test_map', 'e', '1'))
        self.assertOrder(e_dep,
                         (ItemType.CONTAINER, 'test_map', 'a', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None),
                         (ItemType.CONTAINER, 'test_map', 'd', '1'),
                         (ItemType.CONTAINER, 'test_map', 'd', '2'))
Пример #3
0
 def setUp(self):
     test_map = ContainerMap('test_map',
                             initial=TEST_MAP_DATA,
                             check_integrity=False)
     dependency_items = list(test_map.dependency_items())
     self.f_res = ContainerDependencyResolver(dependency_items)
     self.r_res = ContainerDependentsResolver(dependency_items)
Пример #4
0
class ContainerDependencyTest(unittest.TestCase):
    def setUp(self):
        test_map = ContainerMap('test_map',
                                initial=TEST_MAP_DATA,
                                check_integrity=False)
        dependency_items = list(test_map.dependency_items())
        self.f_res = ContainerDependencyResolver(dependency_items)
        self.r_res = ContainerDependentsResolver(dependency_items)

    def assertOrder(self, dependency_list, *items):
        iterator = iter(items)
        last_item = six.next(iterator)
        last_idx = dependency_list.index(last_item)
        for item in iterator:
            index = dependency_list.index(item)
            if index < last_idx:
                self.fail("{0} found before {1}, should be later.".format(
                    item, last_item))

    def test_forward_resolution_order(self):
        a_dep = self.f_res.get_dependencies(
            (ItemType.CONTAINER, 'test_map', 'a', None))
        self.assertOrder(a_dep, (ItemType.VOLUME, 'test_map', 'd', 'dv'),
                         (ItemType.CONTAINER, 'test_map', 'd', '1'),
                         (ItemType.CONTAINER, 'test_map', 'd', '2'),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        self.assertOrder(a_dep, (ItemType.CONTAINER, 'test_map', 'e', '1'),
                         (ItemType.CONTAINER, 'test_map', 'e', '2'),
                         (ItemType.CONTAINER, 'test_map', 'd', '1'),
                         (ItemType.CONTAINER, 'test_map', 'd', '2'))
        self.assertOrder(a_dep, (ItemType.CONTAINER, 'test_map', 'e', '1'),
                         (ItemType.CONTAINER, 'test_map', 'e', '2'),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        self.assertOrder(a_dep, (ItemType.CONTAINER, 'test_map', 'f', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        l_dep = self.f_res.get_dependencies(
            (ItemType.CONTAINER, 'test_map', 'l', None))
        self.assertListEqual(l_dep, [
            (ItemType.IMAGE, 'test_map', 'e', 'latest'),
            (ItemType.CONTAINER, 'test_map', 'e', '1'),
            (ItemType.IMAGE, 'test_map', 'l', 'latest'),
        ])
        x_dep = self.f_res.get_dependencies(
            (ItemType.CONTAINER, 'test_map', 'x', None))
        self.assertOrder(x_dep, (ItemType.CONTAINER, 'test_map', 'f', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))

    def test_backward_resolution_order(self):
        f_dep = self.r_res.get_dependencies(
            (ItemType.CONTAINER, 'test_map', 'f', None))
        self.assertOrder(f_dep, (ItemType.CONTAINER, 'test_map', 'x', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        self.assertOrder(f_dep, (ItemType.CONTAINER, 'test_map', 'a', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None))
        e_dep = self.r_res.get_dependencies(
            (ItemType.CONTAINER, 'test_map', 'e', '1'))
        self.assertOrder(e_dep, (ItemType.CONTAINER, 'test_map', 'a', None),
                         (ItemType.CONTAINER, 'test_map', 'b', None),
                         (ItemType.CONTAINER, 'test_map', 'd', '1'),
                         (ItemType.CONTAINER, 'test_map', 'd', '2'))
class ContainerDependencyTest(unittest.TestCase):
    def setUp(self):
        test_map = ContainerMap('test_map', initial=TEST_MAP_DATA, check_integrity=False)
        self.f_res = ContainerDependencyResolver()
        self.f_res.update(test_map.dependency_items())
        self.r_res = ContainerDependencyResolver()
        self.r_res.update_backward(test_map.dependency_items(reverse=True))

    def assertOrder(self, dependency_list, *items):
        iterator = iter(items)
        last_item = six.next(iterator)
        last_idx = dependency_list.index(last_item)
        for item in iterator:
            index = dependency_list.index(item)
            if index < last_idx:
                self.fail("{0} found before {1}, should be later.".format(item, last_item))

    def test_forward_resolution_order(self):
        a_dep = self.f_res.get_dependencies(('test_map', 'a'))
        self.assertOrder(a_dep,
                         ('test_map', 'd', [None]),
                         ('test_map', 'b', [None]))
        self.assertOrder(a_dep,
                         ('test_map', 'e', [None]),
                         ('test_map', 'd', [None]))
        self.assertOrder(a_dep,
                         ('test_map', 'e', [None]),
                         ('test_map', 'b', [None]))
        self.assertOrder(a_dep,
                         ('test_map', 'f', [None]),
                         ('test_map', 'b', [None]))
        self.assertNotIn(('test_map', 'e', ['1']), a_dep)
        l_dep = self.f_res.get_dependencies(('test_map', 'l'))
        self.assertListEqual(l_dep, [('test_map', 'e', ['1'])])
        x_dep = self.f_res.get_dependencies(('test_map', 'x'))
        self.assertOrder(x_dep,
                         ('test_map', 'f', [None]),
                         ('test_map', 'b', [None]))

    def test_backward_resolution_order(self):
        f_dep = self.r_res.get_dependencies(('test_map', 'f'))
        self.assertOrder(f_dep,
                         ('test_map', 'x', [None]),
                         ('test_map', 'b', [None]))
        self.assertOrder(f_dep,
                         ('test_map', 'a', [None]),
                         ('test_map', 'b', [None]))
        e_dep = self.r_res.get_dependencies(('test_map', 'e'))
        self.assertOrder(e_dep,
                         ('test_map', 'a', [None]),
                         ('test_map', 'b', [None]),
                         ('test_map', 'd', [None]))
class ContainerDependencyTest(unittest.TestCase):
    def setUp(self):
        test_map = ContainerMap("test_map", initial=TEST_MAP_DATA, check_integrity=False)
        self.f_res = ContainerDependencyResolver(test_map)
        self.r_res = ContainerDependencyResolver()
        self.r_res.update_backward(test_map)

    def assertOrder(self, dependency_list, *items):
        iterator = iter(items)
        last_item = six.next(iterator)
        last_idx = dependency_list.index(last_item)
        for item in iterator:
            index = dependency_list.index(item)
            if index < last_idx:
                self.fail("{0} found before {1}, should be later.".format(item, last_item))

    def test_forward_resolution_order(self):
        a_dep = self.f_res.get_container_dependencies("test_map", "a")
        self.assertOrder(a_dep, ("test_map", "d", None), ("test_map", "b", None))
        self.assertOrder(a_dep, ("test_map", "e", None), ("test_map", "d", None))
        self.assertOrder(a_dep, ("test_map", "e", "1"), ("test_map", "b", None))
        self.assertOrder(a_dep, ("test_map", "f", None), ("test_map", "b", None))
        x_dep = self.f_res.get_container_dependencies("test_map", "x")
        self.assertOrder(x_dep, ("test_map", "f", None), ("test_map", "b", None))

    def test_backward_resolution_order(self):
        f_dep = self.r_res.get_container_dependencies("test_map", "f")
        self.assertOrder(f_dep, ("test_map", "x", None), ("test_map", "a", None), ("test_map", "b", None))
        e_dep = self.r_res.get_container_dependencies("test_map", "e")
        self.assertOrder(e_dep, ("test_map", "a", None), ("test_map", "b", None), ("test_map", "d", None))
Пример #7
0
class ContainerDependencyTest(unittest.TestCase):
    def setUp(self):
        test_map = ContainerMap('test_map',
                                initial=TEST_MAP_DATA,
                                check_integrity=False)
        self.f_res = ContainerDependencyResolver(test_map)
        self.r_res = ContainerDependencyResolver()
        self.r_res.update_backward(test_map)

    def assertOrder(self, dependency_list, *items):
        iterator = iter(items)
        last_item = six.next(iterator)
        last_idx = dependency_list.index(last_item)
        for item in iterator:
            index = dependency_list.index(item)
            if index < last_idx:
                self.fail("{0} found before {1}, should be later.".format(
                    item, last_item))

    def test_forward_resolution_order(self):
        a_dep = self.f_res.get_container_dependencies('test_map', 'a')
        self.assertOrder(a_dep, ('test_map', 'd', None),
                         ('test_map', 'b', None))
        self.assertOrder(a_dep, ('test_map', 'e', None),
                         ('test_map', 'd', None))
        self.assertOrder(a_dep, ('test_map', 'e', '1'),
                         ('test_map', 'b', None))
        self.assertOrder(a_dep, ('test_map', 'f', None),
                         ('test_map', 'b', None))
        x_dep = self.f_res.get_container_dependencies('test_map', 'x')
        self.assertOrder(x_dep, ('test_map', 'f', None),
                         ('test_map', 'b', None))

    def test_backward_resolution_order(self):
        f_dep = self.r_res.get_container_dependencies('test_map', 'f')
        self.assertOrder(f_dep, ('test_map', 'x', None),
                         ('test_map', 'b', None))
        self.assertOrder(f_dep, ('test_map', 'a', None),
                         ('test_map', 'b', None))
        e_dep = self.r_res.get_container_dependencies('test_map', 'e')
        self.assertOrder(e_dep, ('test_map', 'a', None),
                         ('test_map', 'b', None), ('test_map', 'd', None))
 def setUp(self):
     test_map = ContainerMap('test_map', initial=TEST_MAP_DATA, check_integrity=False)
     dependency_items = list(test_map.dependency_items())
     self.f_res = ContainerDependencyResolver(dependency_items)
     self.r_res = ContainerDependentsResolver(dependency_items)
 def setUp(self):
     test_map = ContainerMap('test_map', initial=TEST_MAP_DATA, check_integrity=False)
     self.f_res = ContainerDependencyResolver()
     self.f_res.update(test_map.dependency_items())
     self.r_res = ContainerDependencyResolver()
     self.r_res.update_backward(test_map.dependency_items(reverse=True))
Пример #10
0
 def setUp(self):
     test_map = ContainerMap("test_map", initial=TEST_MAP_DATA, check_integrity=False)
     self.f_res = ContainerDependencyResolver(test_map)
     self.r_res = ContainerDependencyResolver()
     self.r_res.update_backward(test_map)