def run(path): templater: Templater = Templater.instance() installer = EnvironmentInstaller(path) installer.install() templater.echo_template('install.jinja2', {'path': path})
def test_get_file_paths(self): installer = EnvironmentInstaller(self.FOLDER_PATH) folder_path = os.path.join( self.FOLDER_PATH, installer.PLATFORM_CONFIG_FOLDER_NAME[platform.system()]) self.assertEqual(installer.get_config_folder_path(), folder_path) self.assertEqual(installer.get_config_file_path(), os.path.join(folder_path, installer.CONFIG_FILE_NAME)) self.assertEqual( installer.get_database_file_path(), os.path.join(folder_path, installer.DATABASE_FILE_NAME))
def test_config_creation_successful(self): installer = EnvironmentInstaller(self.FOLDER_PATH) installer.create_config_folder() installer.create_config_file() self.assertTrue(os.path.exists(installer.get_config_file_path())) with open(installer.get_config_file_path(), mode="r") as file: content = file.read() self.assertTrue("DATABASE" in content) self.assertTrue("BACKEND" in content) self.assertTrue("MOCK_BACKEND_USERS" in content)
def test_database_creation_successful(self): installer = EnvironmentInstaller(self.FOLDER_PATH) installer.create_config_folder() installer.create_database_file() self.assertTrue(os.path.exists(installer.get_database_file_path())) # The Database should be connected to the models now, which one should be able to create a new model and # insert it into the database user = User(name="Jonas", password="******", gold=0, dust=0) user.save() self.assertIsInstance(user, User)
def test_run_installation_successful(self): self.RUNNER.invoke(run, ['--path={}'.format(self.INSTALL_FOLDER)]) installer: EnvironmentInstaller = EnvironmentInstaller( self.INSTALL_FOLDER) # If the installation has indeed worked, the folder and the two files 'config.py # and 'rewardify.db' have to exist now config_folder_path = installer.get_config_folder_path() self.assertTrue(os.path.exists(config_folder_path)) self.assertTrue(os.path.isdir(config_folder_path)) config_file_path = installer.get_config_file_path() self.assertTrue(os.path.exists(config_file_path)) database_file_path = installer.get_database_file_path() self.assertTrue(os.path.exists(database_file_path))
def get_config_folder_path(self): installer: EnvironmentInstaller = EnvironmentInstaller( self.INSTALL_FOLDER) return installer.get_config_folder_path()
def test_database_file_created(self): installer = EnvironmentInstaller(self.FOLDER_PATH) installer.create_config_folder() installer.create_database_file() self.assertTrue(os.path.exists(installer.get_database_file_path()))
def test_init_working(self): installer = EnvironmentInstaller(self.FOLDER_PATH) self.assertEqual(installer.path, self.FOLDER_PATH)