def test_two_graphs(self):
        """
        Two independent graphs
        """
        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]")
Пример #2
0
    def test_two_graphs(self):
        """
        Two independent graphs
        """
        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]")
Пример #3
0
def populate(default_data=True):
    """Populate database with default data"""

    from invenio.config import CFG_PREFIX
    from invenio.config_manager import get_conf

    if not default_data:
        print '>>> No data filled...'
        return

    print ">>> Going to fill tables..."

    load_fixtures()

    conf = get_conf()

    from invenio.inveniocfg import cli_cmd_reset_sitename, \
        cli_cmd_reset_siteadminemail, cli_cmd_reset_fieldnames

    cli_cmd_reset_sitename(conf)
    cli_cmd_reset_siteadminemail(conf)
    cli_cmd_reset_fieldnames(conf)

    for cmd in ["%s/bin/webaccessadmin -u admin -c -a" % CFG_PREFIX]:
        if os.system(cmd):
            print "ERROR: failed execution of", cmd
            sys.exit(1)

    from invenio.inveniocfg_upgrader import InvenioUpgrader
    iu = InvenioUpgrader()
    map(iu.register_success, iu.get_upgrades())

    print ">>> Tables filled successfully."
Пример #4
0
    def test_normal(self):
        """
        Normal dependency graph
        """
        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]")
    def test_normal(self):
        """
        Normal dependency graph
        """
        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]")
Пример #6
0
    def test_missing_dependency(self):
        """
        Missing dependency 0
        """
        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
        """
        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]")
Пример #8
0
    def test_cycle(self):
        """
        Cycle 2, 4, 3.
        """
        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)
Пример #9
0
    def test_cross_graph_dependency(self):
        """
        Missing dependency 0
        """
        upgrades = dictify([
            TestUpgrade('1', [], 'invenio'),
            TestUpgrade('2', ['1'], 'invenio'),
            TestUpgrade('3', ['1', 'b'], 'invenio'),
            TestUpgrade('a', [], 'other'),
            TestUpgrade('b', ['a'], 'other'),
            TestUpgrade('c', ['a'], 'other'),
        ])

        m = InvenioUpgrader()
        self.assertRaises(StandardError, m.order_upgrades, upgrades)
Пример #10
0
    def test_history(self):
        """
        History
        """
        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]")