[feat/test] use pytest-dotenv
This commit is contained in:
parent
1c4a020d22
commit
d23818e318
6 changed files with 37 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -93,6 +93,7 @@ async def index(
|
|||
).all()
|
||||
|
||||
return templates.TemplateResponse(
|
||||
request,
|
||||
"index.html",
|
||||
{
|
||||
"request": request,
|
||||
|
|
31
poetry.lock
generated
31
poetry.lock
generated
|
@ -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"
|
||||
|
|
|
@ -5,6 +5,10 @@ description = ""
|
|||
authors = ["SouthFox <master@southfox.me>"]
|
||||
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"]
|
||||
|
|
9
tasks.py
9
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,
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue