Exemple #1
0
    def test_create_release(self):
        """ Test creation of upgrades """
        from invenio.modules.upgrader.engine import InvenioUpgrader
        from invenio.modules.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
Exemple #2
0
    def test_create(self):
        """ Test creation of upgrades """
        from invenio.modules.upgrader.commands import \
            cmd_upgrade_create_standard_recipe

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

        # Test if upgrade can be imported
        expexted_name = "mymod_%s_rename_me" % \
            date.today().strftime("%Y_%m_%d")

        import invenio_upgrader_test.mymod.upgrades
        upgrade = getattr(
            __import__(
                'invenio_upgrader_test.mymod.upgrades',
                globals(), locals(), [expexted_name], -1
            ),
            expexted_name
        )
        # Test API of created upgrade recipe
        assert upgrade.depends_on == ['test1', 'test2']
        assert upgrade.estimate() == 1
        assert isinstance(upgrade.info(), six.string_types)
        upgrade.pre_upgrade()
        upgrade.do_upgrade()
        upgrade.post_upgrade()
Exemple #3
0
    def test_double_create(self):
        """ Test creation of upgrades """
        from invenio.modules.upgrader.commands import \
            cmd_upgrade_create_standard_recipe

        cmd_upgrade_create_standard_recipe('invenio_upgrader_test')
        # Second call fails since module already exists, and we didn't
        # rename it yet.
        self.assertRaises(
            SystemExit,
            cmd_upgrade_create_standard_recipe,
            'invenio_upgrader_test',
        )
Exemple #4
0
    def test_double_create(self):
        """ Test creation of upgrades """
        from invenio.modules.upgrader.commands import \
            cmd_upgrade_create_standard_recipe

        cmd_upgrade_create_standard_recipe('invenio_upgrader_test')
        # Second call fails since module already exists, and we didn't
        # rename it yet.
        self.assertRaises(
            SystemExit,
            cmd_upgrade_create_standard_recipe,
            'invenio_upgrader_test',
        )
Exemple #5
0
def recipe(package, repository=None, depends_on=None, release=False,
           output_path=None, auto=False, overwrite=False, name=None):
    """
    Create a new upgrade recipe (for developers).
    """
    from invenio.modules.upgrader.commands import \
        cmd_upgrade_create_standard_recipe
    cmd_upgrade_create_standard_recipe(
        package,
        depends_on=depends_on,
        repository=repository,
        release=release,
        output_path=output_path,
        auto=auto,
        overwrite=overwrite,
        name=name,
    )
Exemple #6
0
def recipe(package, repository=None, depends_on=None, release=False,
           output_path=None, auto=False, overwrite=False, name=None):
    """
    Create a new upgrade recipe (for developers).
    """
    from invenio.modules.upgrader.commands import \
        cmd_upgrade_create_standard_recipe
    cmd_upgrade_create_standard_recipe(
        package,
        depends_on=depends_on,
        repository=repository,
        release=release,
        output_path=output_path,
        auto=auto,
        overwrite=overwrite,
        name=name,
    )
Exemple #7
0
    def test_create_load_engine(self):
        """ Test creation and loading of upgrades with engine """
        from invenio.modules.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.modules.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'
Exemple #8
0
    def test_create_load_engine(self):
        """ Test creation and loading of upgrades with engine """
        from invenio.modules.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.modules.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'
Exemple #9
0
    def test_create(self):
        """ Test creation of upgrades """
        from invenio.modules.upgrader.commands import \
            cmd_upgrade_create_standard_recipe

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

        # Test if upgrade can be imported
        expexted_name = "mymod_%s_rename_me" % \
            date.today().strftime("%Y_%m_%d")

        import invenio_upgrader_test.mymod.upgrades
        upgrade = getattr(
            __import__('invenio_upgrader_test.mymod.upgrades', globals(),
                       locals(), [expexted_name], -1), expexted_name)
        # Test API of created upgrade recipe
        assert upgrade.depends_on == ['test1', 'test2']
        assert upgrade.estimate() == 1
        assert isinstance(upgrade.info(), six.string_types)
        upgrade.pre_upgrade()
        upgrade.do_upgrade()
        upgrade.post_upgrade()
Exemple #10
0
    def test_create_release(self):
        """ Test creation of upgrades """
        from invenio.modules.upgrader.engine import InvenioUpgrader
        from invenio.modules.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