forgejo-integration-testing/tests/conftest.py
Michał Szczepanik 22498a7408 Test encryption with mask special remote
This test is longer and has more of a workflow (set-up, push, clone,
get) than the other tests which check more isolated / well defined
behaviors, so it seems appropriate to put it in a separate file called
test_workflows.

This test is also unique in that it relies on gpg and requires a gpg key
to be specified (by id), and gets skipped if the `--gpg-keyid` argument
is not provided (or if gpg does not have a matching private key). The
idea is to have a throwaway key ready and gpg set up.

I was looking for maybe using stateless (thinking we might add the
throwaway key to the tests repo), but git-annex only supports it for the
shared mode (unencrypted cipher in git repo), which would not make sense
with forgejo.

The assertions are perhaps a little redundant (metadata-based
availability from whereis, remote checks with checkpresentkey, trying to
get files) but I wasn't sure what would be the best set of checks.
2026-07-03 14:59:40 +02:00

33 lines
956 B
Python

import os
import pytest
from forgejo_integration_testing.forgejo import ForgejoMiniClient
from forgejo_integration_testing.wordsmith import Words
def pytest_addoption(parser):
parser.addoption("--instance-url", dest="instance_url", required=True)
parser.addoption("--org")
parser.addoption("--gpg-keyid", dest="gpg_keyid")
@pytest.fixture(scope="session")
def forgejo(pytestconfig):
"""Initialize a forgejo client object
Tests need it for interacting with the API. We read the token from
the environment variable here.
"""
forgejo_url = pytestconfig.getoption("instance_url")
forgejo_token = os.getenv("FORGEJO_TOKEN")
if forgejo_token is None:
raise RuntimeError("We need a token but FORGEJO_TOKEN env var is not defined")
return ForgejoMiniClient(forgejo_url, forgejo_token)
@pytest.fixture(scope="session")
def words():
"""Initialize a random word (name) generator"""
return Words()