Example #1
0
def test_update_no_version_change(dbbackup, update, get_version):
    """
    Tests that when the version doesn't change, we are not doing things we
    shouldn't
    """
    main.initialize()
    update.assert_not_called()
    dbbackup.assert_not_called()
Example #2
0
    def invoke(self, ctx):
        try:
            initialize(**get_initialize_params())
        except Exception as e:
            raise click.ClickException(e)

        # Remove parameters that are not for Django management command
        for param in initialize_params:
            ctx.params.pop(param.name)
        return super(KolibriDjangoCommand, self).invoke(ctx)
Example #3
0
def test_migrate_if_unmigrated(version_updated, _migrate_databases):
    # No matter what, ensure that version_updated returns False
    version_updated.return_value = False
    from morango.models import InstanceIDModel

    with patch.object(InstanceIDModel, "get_or_create_current_instance"
                      ) as get_or_create_current_instance:
        get_or_create_current_instance.side_effect = OperationalError("Test")
        main.initialize()
        _migrate_databases.assert_called_once()
Example #4
0
def test_update_exits_if_running(get_version):
    """
    Tests that update() function performs as expected
    """
    with patch("kolibri.utils.main.get_status"):
        try:
            main.initialize()
            pytest.fail("Update did not exit when Kolibri was already running")
        except SystemExit:
            pass
Example #5
0
def test_first_run(dbbackup, update, get_version):
    """
    Tests that the first_run() function performs as expected
    """

    main.initialize()
    update.assert_called_once()
    dbbackup.assert_not_called()

    # Check that it got called for each default plugin
    from kolibri import plugins

    assert set(plugins.config["INSTALLED_PLUGINS"]) == set(
        plugins.DEFAULT_PLUGINS)
Example #6
0
def test_update(update, get_version):
    """
    Tests that update() function performs as expected
    """
    main.initialize()
    update.assert_called_once()