예제 #1
0
def test_update(update, version_file=None, orig_version=None):
    """
    Tests that update() function performs as expected
    """
    version_file = cli.version_file()
    open(version_file, "w").write(orig_version + "_test")
    cli.initialize()
    update.assert_called_once()
예제 #2
0
    def wrapper(*args, **kwargs):
        version_file = cli.version_file()
        version_file_existed = os.path.isfile(version_file)
        orig_version = kolibri.__version__
        kwargs["orig_version"] = orig_version

        if version_file_existed:
            kwargs["version_file"] = version_file

        func(*args, **kwargs)

        if version_file_existed:
            open(version_file, "w").write(orig_version)
예제 #3
0
def test_update_no_version_change(dbbackup,
                                  update,
                                  version_file=None,
                                  orig_version=None):
    """
    Tests that when the version doesn't change, we are not doing things we
    shouldn't
    """
    version_file = cli.version_file()
    open(version_file, "w").write(orig_version)
    cli.initialize()
    update.assert_not_called()
    dbbackup.assert_not_called()
예제 #4
0
    def wrapper(*args, **kwargs):
        version_file = cli.version_file()
        version_file_existed = os.path.isfile(version_file)
        orig_version = kolibri.__version__
        kwargs['orig_version'] = orig_version

        if version_file_existed:
            kwargs['version_file'] = version_file

        func(*args, **kwargs)

        if version_file_existed:
            open(version_file, "w").write(orig_version)
예제 #5
0
def test_update(update, version_file=None, orig_version=None):
    """
    Tests that update() function performs as expected, creating a database
    backup automatically when version changes
    """
    version_file = cli.version_file()
    open(version_file, "w").write(orig_version + "_test")

    if is_sqlite_settings():
        with patch('kolibri.core.deviceadmin.utils.dbbackup') as dbbackup:
            cli.initialize()
            dbbackup.assert_called_once()
    else:
        cli.initialize()
    update.assert_called_once()
예제 #6
0
def test_update(update, version_file=None, orig_version=None):
    """
    Tests that update() function performs as expected, creating a database
    backup automatically when version changes
    """
    version_file = cli.version_file()
    open(version_file, "w").write(orig_version + "_test")

    if is_sqlite_settings():
        with patch('kolibri.core.deviceadmin.utils.dbbackup') as dbbackup:
            cli.initialize()
            dbbackup.assert_called_once()
    else:
        cli.initialize()
    update.assert_called_once()
예제 #7
0
 def test_content_dir_dne(self, logging_mock, version_file=None, orig_version=None):
     version_file = cli.version_file()
     open(version_file, "w").write(orig_version)
     with self.assertRaises(SystemExit):
         cli.main(["start"])
         logging_mock.assert_called()