def get_available_settings(): """Return settings available on the current project""" try: project = Project() except (ValueError, SettingsModified): return None return project.get_available_settings().__members__
def test_container_variables(testproj): with testproj as projdir: conf_file = Path(projdir) / "derex.config.yaml" config = { "project_name": "minimal", "variables": { "lms_site_name": { "base": "dev.onlinecourses.example", "production": "onlinecourses.example", } }, } conf_file.write_text(yaml.dump(config)) create_settings_file(Path(projdir), "production") project = Project() env = project.get_container_env() assert "DEREX_LMS_SITE_NAME" in env assert env["DEREX_LMS_SITE_NAME"] == "dev.onlinecourses.example" project.settings = project.get_available_settings().production env = project.get_container_env() assert env["DEREX_LMS_SITE_NAME"] == "onlinecourses.example"
def test_container_variables(minimal_project): with minimal_project: conf_file = Project().root / CONF_FILENAME config = { "project_name": "minimal", "variables": { "lms_site_name": { "default": "dev.onlinecourses.example", "production": "onlinecourses.example", } }, } conf_file.write_text(yaml.dump(config)) create_settings_file(Project().root, "production") project = Project() env = project.get_container_env() assert "DEREX_LMS_SITE_NAME" in env assert env["DEREX_LMS_SITE_NAME"] == "dev.onlinecourses.example" project.settings = project.get_available_settings().production env = project.get_container_env() assert env["DEREX_LMS_SITE_NAME"] == "onlinecourses.example"