clean separation of zope.testrunner tests (in scopes/tests) and pytest tests (in tests)
This commit is contained in:
parent
b6ef05008b
commit
afe858fc9f
4 changed files with 73 additions and 8 deletions
|
|
@ -11,7 +11,7 @@ license = {text = "MIT"}
|
||||||
keywords = ["scopes"]
|
keywords = ["scopes"]
|
||||||
authors = [{name = "Helmut Merz", email = "helmutm@cy55.de"}]
|
authors = [{name = "Helmut Merz", email = "helmutm@cy55.de"}]
|
||||||
|
|
||||||
dependencies = ["SQLAlchemy", "pydantic-settings"]
|
dependencies = ["SQLAlchemy", "pydantic", "pydantic-settings"]
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
postgres = [
|
postgres = [
|
||||||
|
|
@ -19,7 +19,7 @@ postgres = [
|
||||||
"transaction",
|
"transaction",
|
||||||
"zope.sqlalchemy",
|
"zope.sqlalchemy",
|
||||||
]
|
]
|
||||||
app = [
|
app = [ # TODO: rename to zope
|
||||||
"python-dotenv",
|
"python-dotenv",
|
||||||
"waitress",
|
"waitress",
|
||||||
"zope.authentication",
|
"zope.authentication",
|
||||||
|
|
@ -27,9 +27,9 @@ app = [
|
||||||
"zope.publisher",
|
"zope.publisher",
|
||||||
"zope.traversing",
|
"zope.traversing",
|
||||||
]
|
]
|
||||||
auth = ["pyjwt[crypto]", "cryptography", "requests"]
|
|
||||||
api = ["fastapi[standard]"]
|
api = ["fastapi[standard]"]
|
||||||
test = ["zope.testrunner", "pydantic-settings"]
|
auth = ["pyjwt[crypto]", "cryptography", "requests"]
|
||||||
|
test = ["zope.testrunner"] # TODO: rename to zopetest, or merge with apitest
|
||||||
apitest = ["pytest", "httpx2"]
|
apitest = ["pytest", "httpx2"]
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
|
|
@ -37,7 +37,7 @@ packages = ["scopes"]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = ["-s"]
|
addopts = ["-s"]
|
||||||
#test_paths = ["tests"]
|
testpaths = ["tests"]
|
||||||
python_files = ["test_api.py"]
|
#python_files = ["test_api.py"]
|
||||||
# use .pytest.ini file with `python_files = test_*.py` to run all tests
|
# use .pytest.ini file for local test config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# runtests.sh
|
# runtests.sh
|
||||||
# run all unit / doc tests
|
# run all unit / doc tests
|
||||||
|
|
||||||
zope-testrunner --test-path=. -m !test_api $*
|
#zope-testrunner --test-path=. -m !test_api $*
|
||||||
|
zope-testrunner --test-path=. $*
|
||||||
|
|
||||||
|
|
|
||||||
64
tests/config.py
Normal file
64
tests/config.py
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
# py-scopes/tests/config.py
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_file='.env')
|
||||||
|
|
||||||
|
base_url: str = 'https://test.cy7.eu'
|
||||||
|
|
||||||
|
log_file: str = 'scopes/tests/log/scopes-test.log'
|
||||||
|
log_level: str = 'INFO'
|
||||||
|
log_format: str = '%(asctime)s %(levelname)s %(name)s %(message)s'
|
||||||
|
log_dateformat: str = '%Y-%m-%dT%H:%M:%S'
|
||||||
|
|
||||||
|
|
||||||
|
dbengine: str = 'sqlite'
|
||||||
|
dbname: str = 'var/test.db'
|
||||||
|
dbuser: str | None = None
|
||||||
|
dbpassword: str | None = None
|
||||||
|
dbschema: str | None = None
|
||||||
|
|
||||||
|
settings = Settings()
|
||||||
|
|
||||||
|
from os import getenv
|
||||||
|
import sys
|
||||||
|
|
||||||
|
base_url = settings.base_url
|
||||||
|
|
||||||
|
logging.basicConfig(filename=settings.log_file, level=settings.log_level,
|
||||||
|
format=settings.log_format, datefmt=settings.log_dateformat)
|
||||||
|
|
||||||
|
# SQLite storage settings
|
||||||
|
dbengine = settings.dbengine
|
||||||
|
dbname = settings.dbname
|
||||||
|
dbuser = settings.dbuser
|
||||||
|
dbpassword = settings.dbpassword
|
||||||
|
dbschema = settings.dbschema
|
||||||
|
|
||||||
|
# special testing stuff
|
||||||
|
from scopes.tests import data_auth # add oidc URIs and keys to dummy_requests data
|
||||||
|
from scopes.tests import dummy_requests
|
||||||
|
sys.modules['requests'] = dummy_requests
|
||||||
|
|
||||||
|
# authentication settings
|
||||||
|
oidc_provider = 'test://oidc'
|
||||||
|
oidc_client_id = getenv('OIDC_CLIENT_ID', '12345')
|
||||||
|
oidc_params = dict(
|
||||||
|
op_config_url=oidc_provider + '/.well-known/openid-configuration',
|
||||||
|
op_uris=None,
|
||||||
|
op_keys=None,
|
||||||
|
op_project_scope='urn:zitadel:iam:org:project:id:zitadel:aud',
|
||||||
|
callback_url=getenv('OIDC_CALLBACK_URL', base_url + '/auth/callback'),
|
||||||
|
client_id=oidc_client_id,
|
||||||
|
principal_prefix=getenv('OIDC_PRINCIPAL_PREFIX', 'loops.'),
|
||||||
|
cookie_name=getenv('OIDC_COOKIE_NAME', 'oidc_' + oidc_client_id),
|
||||||
|
cookie_domain=getenv('OIDC_COOKIE_DOMAIN', None),
|
||||||
|
cookie_lifetime=getenv('OIDC_COOKIE_LIFETIME', '86400'),
|
||||||
|
cookie_crypt=getenv('OIDC_COOKIE_CRYPT', None),
|
||||||
|
private_key_file=getenv('OIDC_SERVICE_USER_PRIVATE_KEY_FILE',
|
||||||
|
'scopes/tests/test-private-key.json'),
|
||||||
|
organization_id=getenv('OIDC_ORGANIZATION_ID', '12346'),
|
||||||
|
project_id=getenv('OIDC_PROJECT_ID', None),
|
||||||
|
)
|
||||||
Loading…
Add table
Reference in a new issue