def test_two_graphs(self):
        """
        Two independent graphs
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1'], 'invenio'),

            TestUpgrade('a', [], 'other'),
            TestUpgrade('b', ['a'], 'other'),
            TestUpgrade('c', ['a'], 'other'),

            TestUpgrade('4', ['2'], 'invenio'),
            TestUpgrade('5', ['3', '4'], 'invenio'),
            TestUpgrade('6', ['5', ], 'invenio'),

            TestUpgrade('d', ['b'], 'other'),
            TestUpgrade('e', ['c', 'd'], 'other'),
            TestUpgrade('f', ['e', ], 'other'),
        ])

        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)),
                         "[1, 2, 4, 3, 5, 6, a, b, d, c, e, f]")
    def test_two_graphs(self):
        """
        Two independent graphs
        """
        from invenio_upgrader.engine import InvenioUpgrader

        upgrades = dictify(
            [
                TestUpgrade("1", [], "invenio"),
                TestUpgrade("2", ["1"], "invenio"),
                TestUpgrade("3", ["1"], "invenio"),
                TestUpgrade("a", [], "other"),
                TestUpgrade("b", ["a"], "other"),
                TestUpgrade("c", ["a"], "other"),
                TestUpgrade("4", ["2"], "invenio"),
                TestUpgrade("5", ["3", "4"], "invenio"),
                TestUpgrade("6", ["5"], "invenio"),
                TestUpgrade("d", ["b"], "other"),
                TestUpgrade("e", ["c", "d"], "other"),
                TestUpgrade("f", ["e"], "other"),
            ]
        )

        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)), "[1, 2, 4, 3, 5, 6, a, b, d, c, e, f]")
Beispiel #3
0
    def test_two_graphs(self):
        """
        Two independent graphs
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1'], 'invenio'),
            TestUpgrade('a', [], 'other'),
            TestUpgrade('b', ['a'], 'other'),
            TestUpgrade('c', ['a'], 'other'),
            TestUpgrade('4', ['2'], 'invenio'),
            TestUpgrade('5', ['3', '4'], 'invenio'),
            TestUpgrade('6', [
                '5',
            ], 'invenio'),
            TestUpgrade('d', ['b'], 'other'),
            TestUpgrade('e', ['c', 'd'], 'other'),
            TestUpgrade('f', [
                'e',
            ], 'other'),
        ])

        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)),
                         "[1, 2, 4, 3, 5, 6, a, b, d, c, e, f]")
Beispiel #4
0
def test_cross_graph_dependency():
    """Missing dependency 0."""
    from invenio_upgrader.engine import InvenioUpgrader
    upgrades = dictify([
        create_upgrade('1', [], 'invenio'),
        create_upgrade('2', ['1'], 'invenio'),
        create_upgrade('3', ['1', 'b'], 'invenio'),
        create_upgrade('a', [], 'other'),
        create_upgrade('b', ['a'], 'other'),
        create_upgrade('c', ['2'], 'other'),
    ])

    m = InvenioUpgrader()
    # self.assertRaises(Exception, m.order_upgrades, upgrades)
    assert upgrades_str(m.order_upgrades(upgrades)) in [
        "[1, 2, c, a, b, 3]",
        "[1, 2, a, c, b, 3]",
        "[1, 2, a, b, c, 3]",
        "[1, 2, a, b, 3, c]",
        "[1, a, 2, b, c, 3]",
        "[1, a, 2, b, 3, c]",
        "[1, a, 2, c, b, 3]",
        "[1, a, b, 2, c, 3]",
        "[1, a, b, 2, 3, c]",
        "[1, a, b, 3, 2, c]",
        "[a, 1, 2, c, b, 3]",
        "[a, 1, 2, b, c, 3]",
        "[a, 1, 2, b, 3, c]",
        "[a, 1, b, 3, 2, c]",
        "[a, 1, b, 2, 3, c]",
        "[a, 1, b, 2, c, 3]",
        "[a, b, 1, 3, 2, c]",
        "[a, b, 1, 2, c, 3]",
        "[a, b, 1, 2, 3, c]"
    ]
    def test_create_release(self):
        """ Test creation of upgrades """
        from invenio_upgrader.engine import InvenioUpgrader
        from invenio_upgrader.commands import \
            cmd_upgrade_create_standard_recipe, \
            cmd_upgrade_create_release_recipe

        engine = InvenioUpgrader(packages=[
            'invenio_upgrader_test', 'invenio_upgrader_test.mymod'])

        cmd_upgrade_create_standard_recipe(
            'invenio_upgrader_test', depends_on=[]
        )
        cmd_upgrade_create_standard_recipe(
            'invenio_upgrader_test.mymod', depends_on=[]
        )

        cmd_upgrade_create_release_recipe(
            'invenio_upgrader_test', repository='invenio', upgrader=engine
        )

        # Find all endpoints in all repositories
        upgrades = engine.get_upgrades(remove_applied=False)
        for u in upgrades:
            if u['id'] == 'invenio_release_x_y_z':
                assert len(u['depends_on']) == 2
Beispiel #6
0
def test_missing_dependency():
    """Missing dependency 0."""
    from invenio_upgrader.engine import InvenioUpgrader
    upgrades = dictify([
        create_upgrade('1', [], 'invenio'),
        create_upgrade('2', ['1'], 'invenio'),
        create_upgrade('3', ['1', '0'], 'invenio'),
    ])

    m = InvenioUpgrader()
    with pytest.raises(Exception):
        m.order_upgrades(upgrades)
Beispiel #7
0
def test_cycle_graph():
    """Cycle 2, 4, 3."""
    from invenio_upgrader.engine import InvenioUpgrader
    upgrades = dictify([
        create_upgrade('1', [], 'invenio'),
        create_upgrade('2', ['1', '3'], 'invenio'),
        create_upgrade('3', ['1', '4'], 'invenio'),
        create_upgrade('4', ['2'], 'invenio'),
        create_upgrade('5', ['3', '4'], 'invenio'),
        create_upgrade('6', ['5', ], 'invenio'),
    ])

    m = InvenioUpgrader()
    with pytest.raises(Exception):
        m.order_upgrades(upgrades)
    def test_create_load_engine(self):
        """ Test creation and loading of upgrades with engine """
        from invenio_upgrader.commands import cmd_upgrade_create_standard_recipe

        cmd_upgrade_create_standard_recipe("invenio_upgrader_test", depends_on=[])

        expexted_name = "invenio_upgrader_test_%s_rename_me" % date.today().strftime("%Y_%m_%d")

        # Test if upgrade can be found from the Upgrade
        from invenio_upgrader.engine import InvenioUpgrader

        eng = InvenioUpgrader(packages=["invenio_upgrader_test"])
        upgrades = eng.get_upgrades(remove_applied=False)
        assert len(upgrades) == 1
        assert upgrades[0]["id"] == expexted_name
        assert upgrades[0]["repository"] == "invenio_upgrader_test"
    def test_normal(self):
        """
        Normal dependency graph
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1'], 'invenio'),
            TestUpgrade('4', ['2'], 'invenio'),
            TestUpgrade('5', ['3', '4'], 'invenio'),
            TestUpgrade('6', ['5', ], 'invenio'),
        ])

        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)),
                         "[1, 2, 4, 3, 5, 6]")
Beispiel #10
0
def test_normal_graph():
    """Normal dependency graph."""
    from invenio_upgrader.engine import InvenioUpgrader
    upgrades = dictify([
        create_upgrade('1', [], 'invenio'),
        create_upgrade('2', ['1'], 'invenio'),
        create_upgrade('3', ['1'], 'invenio'),
        create_upgrade('4', ['2'], 'invenio'),
        create_upgrade('5', ['3', '4'], 'invenio'),
        create_upgrade('6', ['5', ], 'invenio'),
    ])
    m = InvenioUpgrader()
    assert upgrades_str(m.order_upgrades(upgrades)) in [
        "[1, 2, 3, 4, 5, 6]",
        "[1, 2, 4, 3, 5, 6]",
        "[1, 3, 2, 4, 5, 6]",
    ]
    def test_create_release(self):
        """ Test creation of upgrades """
        from invenio_upgrader.engine import InvenioUpgrader
        from invenio_upgrader.commands import cmd_upgrade_create_standard_recipe, cmd_upgrade_create_release_recipe

        engine = InvenioUpgrader(packages=["invenio_upgrader_test", "invenio_upgrader_test.mymod"])

        cmd_upgrade_create_standard_recipe("invenio_upgrader_test", depends_on=[])
        cmd_upgrade_create_standard_recipe("invenio_upgrader_test.mymod", depends_on=[])

        cmd_upgrade_create_release_recipe("invenio_upgrader_test", repository="invenio", upgrader=engine)

        # Find all endpoints in all repositories
        upgrades = engine.get_upgrades(remove_applied=False)
        for u in upgrades:
            if u["id"] == "invenio_release_x_y_z":
                assert len(u["depends_on"]) == 2
    def test_cross_graph_dependency(self):
        """
        Missing dependency 0
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1', 'b'], 'invenio'),
            TestUpgrade('a', [], 'other'),
            TestUpgrade('b', ['a'], 'other'),
            TestUpgrade('c', ['2'], 'other'),
        ])

        m = InvenioUpgrader()
        #self.assertRaises(StandardError, m.order_upgrades, upgrades)
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)),
                         "[1, 2, c, a, b, 3]")
Beispiel #13
0
    def test_create_load_engine(self):
        """ Test creation and loading of upgrades with engine """
        from invenio_upgrader.commands import \
            cmd_upgrade_create_standard_recipe

        cmd_upgrade_create_standard_recipe('invenio_upgrader_test',
                                           depends_on=[])

        expexted_name = "invenio_upgrader_test_%s_rename_me" % \
            date.today().strftime("%Y_%m_%d")

        # Test if upgrade can be found from the Upgrade
        from invenio_upgrader.engine import InvenioUpgrader
        eng = InvenioUpgrader(packages=['invenio_upgrader_test'])
        upgrades = eng.get_upgrades(remove_applied=False)
        assert len(upgrades) == 1
        assert upgrades[0]['id'] == expexted_name
        assert upgrades[0]['repository'] == 'invenio_upgrader_test'
Beispiel #14
0
    def test_cross_graph_dependency(self):
        """
        Missing dependency 0
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1', 'b'], 'invenio'),
            TestUpgrade('a', [], 'other'),
            TestUpgrade('b', ['a'], 'other'),
            TestUpgrade('c', ['2'], 'other'),
        ])

        m = InvenioUpgrader()
        #self.assertRaises(StandardError, m.order_upgrades, upgrades)
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)),
                         "[1, 2, c, a, b, 3]")
    def test_normal(self):
        """
        Normal dependency graph
        """
        from invenio_upgrader.engine import InvenioUpgrader

        upgrades = dictify(
            [
                TestUpgrade("1", [], "invenio"),
                TestUpgrade("2", ["1"], "invenio"),
                TestUpgrade("3", ["1"], "invenio"),
                TestUpgrade("4", ["2"], "invenio"),
                TestUpgrade("5", ["3", "4"], "invenio"),
                TestUpgrade("6", ["5"], "invenio"),
            ]
        )

        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)), "[1, 2, 4, 3, 5, 6]")
Beispiel #16
0
    def test_normal(self):
        """
        Normal dependency graph
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1'], 'invenio'),
            TestUpgrade('4', ['2'], 'invenio'),
            TestUpgrade('5', ['3', '4'], 'invenio'),
            TestUpgrade('6', [
                '5',
            ], 'invenio'),
        ])

        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)),
                         "[1, 2, 4, 3, 5, 6]")
Beispiel #17
0
def test_two_graphs_graphs():
    """Two independent graphs."""
    from invenio_upgrader.engine import InvenioUpgrader
    upgrades = dictify([
        create_upgrade('1', [], 'invenio'),
        create_upgrade('2', ['1'], 'invenio'),
        create_upgrade('3', ['1'], 'invenio'),

        create_upgrade('a', [], 'other'),
        create_upgrade('b', ['a'], 'other'),
        create_upgrade('c', ['a'], 'other'),

        create_upgrade('4', ['2'], 'invenio'),
        create_upgrade('5', ['3', '4'], 'invenio'),
        create_upgrade('6', ['5', ], 'invenio'),

        create_upgrade('d', ['b'], 'other'),
        create_upgrade('e', ['c', 'd'], 'other'),
        create_upgrade('f', ['e', ], 'other'),
    ])

    m = InvenioUpgrader()
    assert upgrades_str(m.order_upgrades(upgrades)) in [
        "[1, 2, 4, 3, 5, 6, a, b, d, c, e, f]",
        "[1, 2, 4, 3, 5, 6, a, b, c, d, e, f]",
        "[1, 2, 4, 3, 5, 6, a, c, b, d, e, f]",
        "[1, 2, 3, 4, 5, 6, a, b, d, c, e, f]",
        "[1, 2, 3, 4, 5, 6, a, b, c, d, e, f]",
        "[1, 2, 3, 4, 5, 6, a, c, b, d, e, f]",
        "[1, 3, 2, 4, 5, 6, a, b, d, c, e, f]",
        "[1, 3, 2, 4, 5, 6, a, b, c, d, e, f]",
        "[1, 3, 2, 4, 5, 6, a, c, b, d, e, f]",
        "[a, b, d, c, e, f, 1, 2, 4, 3, 5, 6]",
        "[a, b, c, d, e, f, 1, 2, 4, 3, 5, 6]",
        "[a, c, b, d, e, f, 1, 2, 4, 3, 5, 6]",
        "[a, b, d, c, e, f, 1, 2, 3, 4, 5, 6]",
        "[a, b, c, d, e, f, 1, 2, 3, 4, 5, 6]",
        "[a, c, b, d, e, f, 1, 2, 3, 4, 5, 6]",
        "[a, b, d, c, e, f, 1, 3, 2, 4, 5, 6]",
        "[a, b, c, d, e, f, 1, 3, 2, 4, 5, 6]",
        "[a, c, b, d, e, f, 1, 3, 2, 4, 5, 6]",
        ]
    def test_cross_graph_dependency(self):
        """
        Missing dependency 0
        """
        from invenio_upgrader.engine import InvenioUpgrader

        upgrades = dictify(
            [
                TestUpgrade("1", [], "invenio"),
                TestUpgrade("2", ["1"], "invenio"),
                TestUpgrade("3", ["1", "b"], "invenio"),
                TestUpgrade("a", [], "other"),
                TestUpgrade("b", ["a"], "other"),
                TestUpgrade("c", ["2"], "other"),
            ]
        )

        m = InvenioUpgrader()
        # self.assertRaises(StandardError, m.order_upgrades, upgrades)
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades)), "[1, 2, c, a, b, 3]")
Beispiel #19
0
    def test_history(self):
        """
        History
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1'], 'invenio'),
            TestUpgrade('4', ['2'], 'invenio'),
            TestUpgrade('5', ['3', '4'], 'invenio'),
            TestUpgrade('6', [
                '5',
            ], 'invenio'),
        ])

        history = dictify(['1', '2', '4'], value=1)
        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades, history)),
                         "[3, 5, 6]")

        history = dictify(['3', '5'], value=1)
        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades, history)),
                         "[6]")
Beispiel #20
0
    def test_missing_dependency(self):
        """
        Missing dependency 0
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1', '0'], 'invenio'),
        ])

        m = InvenioUpgrader()
        self.assertRaises(StandardError, m.order_upgrades, upgrades)
    def test_history(self):
        """
        History
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1'], 'invenio'),
            TestUpgrade('4', ['2'], 'invenio'),
            TestUpgrade('5', ['3', '4'], 'invenio'),
            TestUpgrade('6', ['5', ], 'invenio'),
        ])

        history = dictify(['1', '2', '4'], value=1)
        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades, history)),
                         "[3, 5, 6]")

        history = dictify(['3', '5'], value=1)
        m = InvenioUpgrader()
        self.assertEqual(
            upgrades_str(m.order_upgrades(upgrades, history)), "[6]")
Beispiel #22
0
    def test_create_release(self):
        """ Test creation of upgrades """
        from invenio_upgrader.engine import InvenioUpgrader
        from invenio_upgrader.commands import \
            cmd_upgrade_create_standard_recipe, \
            cmd_upgrade_create_release_recipe

        engine = InvenioUpgrader(
            packages=['invenio_upgrader_test', 'invenio_upgrader_test.mymod'])

        cmd_upgrade_create_standard_recipe('invenio_upgrader_test',
                                           depends_on=[])
        cmd_upgrade_create_standard_recipe('invenio_upgrader_test.mymod',
                                           depends_on=[])

        cmd_upgrade_create_release_recipe('invenio_upgrader_test',
                                          repository='invenio',
                                          upgrader=engine)

        # Find all endpoints in all repositories
        upgrades = engine.get_upgrades(remove_applied=False)
        for u in upgrades:
            if u['id'] == 'invenio_release_x_y_z':
                assert len(u['depends_on']) == 2
    def test_history(self):
        """
        History
        """
        from invenio_upgrader.engine import InvenioUpgrader

        upgrades = dictify(
            [
                TestUpgrade("1", [], "invenio"),
                TestUpgrade("2", ["1"], "invenio"),
                TestUpgrade("3", ["1"], "invenio"),
                TestUpgrade("4", ["2"], "invenio"),
                TestUpgrade("5", ["3", "4"], "invenio"),
                TestUpgrade("6", ["5"], "invenio"),
            ]
        )

        history = dictify(["1", "2", "4"], value=1)
        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades, history)), "[3, 5, 6]")

        history = dictify(["3", "5"], value=1)
        m = InvenioUpgrader()
        self.assertEqual(upgrades_str(m.order_upgrades(upgrades, history)), "[6]")
Beispiel #24
0
    def test_cycle(self):
        """
        Cycle 2, 4, 3.
        """
        from invenio_upgrader.engine import InvenioUpgrader
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1', '3'], 'invenio'),
            TestUpgrade('3', ['1', '4'], 'invenio'),
            TestUpgrade('4', ['2'], 'invenio'),
            TestUpgrade('5', ['3', '4'], 'invenio'),
            TestUpgrade('6', [
                '5',
            ], 'invenio'),
        ])

        m = InvenioUpgrader()
        self.assertRaises(StandardError, m.order_upgrades, upgrades)
Beispiel #25
0
def test_history():
    """History."""
    from invenio_upgrader.engine import InvenioUpgrader
    upgrades = dictify([
        create_upgrade('1', [], 'invenio'),
        create_upgrade('2', ['1'], 'invenio'),
        create_upgrade('3', ['1'], 'invenio'),
        create_upgrade('4', ['2'], 'invenio'),
        create_upgrade('5', ['3', '4'], 'invenio'),
        create_upgrade('6', ['5', ], 'invenio'),
    ])

    history = dictify(['1', '2', '4'], value=1)
    m = InvenioUpgrader()
    assert upgrades_str(m.order_upgrades(upgrades, history)) == "[3, 5, 6]"

    history = dictify(['3', '5'], value=1)
    m = InvenioUpgrader()
    assert upgrades_str(m.order_upgrades(upgrades, history)) == "[6]"