feat: implement Fil-A-Management Django MVP
This commit is contained in:
commit
1127e7ecf4
66 files changed
+3774
No files matched your search
@@ -0,0 +1,72 @@
|
||||
"""Synthetic, isolated fixtures. Never access production Docker containers or data."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def clean_environment():
|
||||
env = os.environ.copy()
|
||||
for name in (
|
||||
"PYTHONPATH",
|
||||
"VIRTUAL_ENV",
|
||||
"DJANGO_SETTINGS_MODULE",
|
||||
"DJANGO_SECRET_KEY",
|
||||
"DJANGO_SECRET_KEY_FILE",
|
||||
"GIT_DIR",
|
||||
"GIT_WORK_TREE",
|
||||
):
|
||||
env.pop(name, None)
|
||||
return env
|
||||
|
||||
|
||||
def git_fixture(directory):
|
||||
repo = directory / "repository"
|
||||
repo.mkdir()
|
||||
paths = (
|
||||
subprocess.check_output(
|
||||
["git", "ls-files", "--cached", "--others", "--exclude-standard", "-z"], cwd=ROOT
|
||||
)
|
||||
.decode()
|
||||
.split("\0")
|
||||
)
|
||||
for name in paths:
|
||||
if not name:
|
||||
continue
|
||||
source, destination = ROOT / name, repo / name
|
||||
if source.is_file():
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(source, destination)
|
||||
|
||||
def git(*args):
|
||||
return (
|
||||
subprocess.check_output(
|
||||
[
|
||||
"git",
|
||||
"-c",
|
||||
"user.name=FAM Synthetic Test",
|
||||
"-c",
|
||||
"user.email=test@example.invalid",
|
||||
*args,
|
||||
],
|
||||
cwd=repo,
|
||||
stderr=subprocess.STDOUT,
|
||||
)
|
||||
.decode()
|
||||
.strip()
|
||||
)
|
||||
|
||||
git("init", "-b", "main")
|
||||
(repo / "revision-marker.txt").write_text("first")
|
||||
git("add", ".")
|
||||
git("commit", "-m", "Synthetic revision one")
|
||||
first = git("rev-parse", "HEAD")
|
||||
git("tag", "mvp-test")
|
||||
(repo / "revision-marker.txt").write_text("second")
|
||||
git("add", "revision-marker.txt")
|
||||
git("commit", "-m", "Synthetic revision two")
|
||||
second = git("rev-parse", "HEAD")
|
||||
return repo, first, second
|
||||
Reference in new issue
Block a user