Ejemplo n.º 1
0
def test_populate_settings(testproj):
    with testproj as projdir:

        default_settings_dir = Project().settings_directory_path()
        assert default_settings_dir.is_dir()

        create_settings_file(Path(projdir), "production")
        project = Project(read_only=True)

        assert default_settings_dir != project.settings_directory_path()

        project._populate_settings()
        assert (project.settings_dir / "base.py").is_file(), str(
            sorted((project.settings_dir).iterdir())
        )
        assert (project.settings_dir / "derex").is_dir(), str(
            sorted((project.settings_dir).iterdir())
        )
        base_py = project.settings_dir / "derex" / "base.py"
        assert base_py.is_file()
        assert (project.settings_dir / "derex" / "__init__.py").is_file()

        assert os.access(str(base_py), os.W_OK)

        # In case a settings file was already present, it should be overwritten,
        # even if it lacks owner write permission.
        base_py.write_text("# Changed")
        base_py.chmod(0o444)
        assert not os.access(str(base_py), os.W_OK)
        project._populate_settings()
        assert os.access(str(base_py), os.W_OK)
Ejemplo n.º 2
0
def test_materialize_settings(minimal_project):
    with minimal_project:
        default_settings_dir = Project().settings_directory_path()
        assert default_settings_dir.is_dir()

        create_settings_file(Project().root, "production")
        project = Project(read_only=True)

        assert default_settings_dir != project.settings_directory_path()

        project._materialize_settings()
        assert (project.settings_dir / "__init__.py").is_file(), str(
            sorted((project.settings_dir).iterdir()))
        assert (project.settings_dir / "derex").is_dir(), str(
            sorted((project.settings_dir).iterdir()))
        assets_py = project.settings_dir / "derex" / "build" / "assets.py"
        assert assets_py.is_file()

        base_py = project.settings_dir / "derex" / "default" / "__init__.py"
        assert base_py.is_file()
        assert os.access(str(base_py), os.W_OK)

        # In case a settings file was already present, it should be overwritten,
        # even if it lacks owner write permission.
        base_py.write_text("# Changed")
        base_py.chmod(0o444)
        assert not os.access(str(base_py), os.W_OK)
        project._materialize_settings()
        assert os.access(str(base_py), os.W_OK)
Ejemplo n.º 3
0
def test_populate_settings(testproj):
    with testproj as projdir:

        default_settings_dir = Project().settings_directory_path()
        assert default_settings_dir.is_dir()

        create_settings_file(Path(projdir), "production")
        project = Project(read_only=True)

        assert default_settings_dir != project.settings_directory_path()

        project._populate_settings()
        assert (project.settings_dir / "base.py").is_file(), str(
            sorted((project.settings_dir).iterdir()))
        assert (project.settings_dir / "derex").is_dir(), str(
            sorted((project.settings_dir).iterdir()))
        assert (project.settings_dir / "derex" / "base.py").is_file()
        assert (project.settings_dir / "derex" / "__init__.py").is_file()

        assert not os.access(str(project.settings_dir / "derex" / "base.py"),
                             os.W_OK)