def test_create_db(): prog_manage.create_db() #TODO: Fake os so we can test get_shell_file in any environment assert config.db == { "options": { "Verbose": False, "AutoInstall": False, "ShellFile": config.get_shell_file() }, "version": { "file_version": config.file_version, "prog_internal_version": config.prog_internal_version, "branch": "master" }, "programs": { } }
def create_db(): """Creates Database.""" db_template = { "options": { "Verbose": False, "AutoInstall": False, "ShellFile": config.get_shell_file() }, "version": { "file_version": config.file_version, "prog_internal_version": config.prog_internal_version, "branch": "master" }, "programs": { } } config.db = db_template config.write_db()
def test_get_db(): assert config.get_db() == { "options": { "Verbose": False, "AutoInstall": False, "ShellFile": config.get_shell_file() }, "version": { "file_version": config.file_version, "prog_internal_version": config.prog_internal_version, "branch": "master" }, "programs": { "package": { "desktops": [] } } }
config.vprint("Removing old database") os.remove(config.full("~/.hamstall/database")) except FileNotFoundError: pass config.vprint("Creating new database") config.create("~/.hamstall/database") prog_manage.create_db() config.vprint("Upgraded from hamstall file version 1 to 2.") elif file_version == 2: config.vprint("Database needs to have the branch key! Adding...") config.db["version"].update({"branch": "master"}) config.db["version"]["file_version"] = 3 config.vprint("Upgraded from hamstall file version 2 to 3.") elif file_version == 3: config.vprint("Database needs to have the shell key! Adding...") config.db["options"].update({"ShellFile": config.get_shell_file()}) config.db["version"]["file_version"] = 4 config.vprint("Upgraded from hamstall file version 3 to 4.") elif file_version == 4: config.vprint("file.py merged into config.py; deleting old file.py...") try: os.remove(config.full("~/.hamstall/file.py")) config.vprint("Deleted file.py") except FileNotFoundError: pass config.vprint("file.py not found, so not deleted!") config.db["version"]["file_version"] = 5 config.vprint("Upgraded from hamstall file version 4 to 5.") try: file_version = prog_manage.get_file_version('file') except KeyError: