diff --git a/app/config.py b/app/config.py index 00c419c..1e660b8 100644 --- a/app/config.py +++ b/app/config.py @@ -67,7 +67,7 @@ _SCHEME = "https" if CONFIG.https else "http" ID = f"{_SCHEME}://{DOMAIN}" BASE_URL = ID USERNAME = CONFIG.username -KEY_PATH = (ROOT_DIR / "data" / "key.pem") +KEY_PATH = (ROOT_DIR / os.getenv("FOXHOLE_KEY_PATH", "data/key.pem")) VERSION = "Foxhole-"+ MAIN_VERSION + get_version_commit() USER_AGENT = "Fediverse Application/" + VERSION diff --git a/app/main.py b/app/main.py index 12c7bc3..3c75f57 100644 --- a/app/main.py +++ b/app/main.py @@ -93,6 +93,7 @@ async def index( ).all() return templates.TemplateResponse( + request, "index.html", { "request": request, diff --git a/poetry.lock b/poetry.lock index 156c886..61a400d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1024,6 +1024,21 @@ pytest = ">=7.0.0,<9" docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"] +[[package]] +name = "pytest-dotenv" +version = "0.5.2" +description = "A py.test plugin that parses environment files before running tests" +optional = false +python-versions = "*" +files = [ + {file = "pytest-dotenv-0.5.2.tar.gz", hash = "sha256:2dc6c3ac6d8764c71c6d2804e902d0ff810fa19692e95fe138aefc9b1aa73732"}, + {file = "pytest_dotenv-0.5.2-py3-none-any.whl", hash = "sha256:40a2cece120a213898afaa5407673f6bd924b1fa7eafce6bda0e8abffe2f710f"}, +] + +[package.dependencies] +pytest = ">=5.0.0" +python-dotenv = ">=0.9.1" + [[package]] name = "python-dateutil" version = "2.8.2" @@ -1038,6 +1053,20 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "python-dotenv" +version = "1.0.1" +description = "Read key-value pairs from a .env file and set them as environment variables" +optional = false +python-versions = ">=3.8" +files = [ + {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"}, + {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"}, +] + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "requests" version = "2.31.0" @@ -1295,4 +1324,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "bad9633f9f1574ead14723ac09f573ecd5602c285624089ffd621ec3c244f349" +content-hash = "e4cf8ef593d76d86515028f6e5c693e0749ba5d1df9ab9deec1a995558bc56c5" diff --git a/pyproject.toml b/pyproject.toml index 1f559bb..375a59c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,10 @@ description = "" authors = ["SouthFox "] readme = "README.org" +[tool.pytest_env] +FOXHOLE_CONFIG_FILE = "tests.toml" +FOXHOLE_KEY_PATH = "tests/key.pem" + [tool.poetry.dependencies] python = "^3.11" fastapi = "^0.110.0" @@ -32,6 +36,7 @@ pytest-asyncio = "^0.23.5" respx = "^0.20.2" factory-boy = "^3.2.1" black = "^23.7.0" +pytest-dotenv = "^0.5.2" [build-system] requires = ["poetry-core"] diff --git a/tasks.py b/tasks.py index d0c182b..f6c3419 100644 --- a/tasks.py +++ b/tasks.py @@ -168,12 +168,3 @@ def send_note(ctx): print("Done!") asyncio.run(_dodo()) - - -@task -def tests(ctx): - run( - f"FOXHOLE_CONFIG_FILE=tests.toml pytest -vvv", - pty=True, - echo=True, - ) diff --git a/tests/test_outbox.py b/tests/test_outbox.py index 97239ee..c72a153 100644 --- a/tests/test_outbox.py +++ b/tests/test_outbox.py @@ -68,8 +68,6 @@ async def test_outbox_send_follow_request( assert inbox_object.ap_type == "Accept" - - @pytest.mark.asyncio async def test_outbox_send_follow_request_nest_accept( db: Session, @@ -156,5 +154,4 @@ async def test_outbox_send_create_activity( # And the Follow activity was created in the outbox outbox_object = db.execute(select(models.OutboxObject)).scalar_one() assert outbox_object.ap_type == "Note" - print(outbox_object.ap_object["content"]) assert outbox_object.ap_object["content"] == content