From 4bb7407b0b1378b1e788944dde5d4367aa1534b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Meki=C4=87?= Date: Sat, 21 Jun 2025 01:33:59 +0200 Subject: [PATCH] Simplify project generation --- alembic/README | 1 - bin/test.sh | 2 +- freenit/__init__.py | 2 +- freenit/cli.py | 7 ++++--- freenit/models/ldap/group.py | 2 +- migrate.py | 3 ++- pytest.ini | 2 -- tests/conftest.py | 7 ++----- 8 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 alembic/README delete mode 100644 pytest.ini diff --git a/alembic/README b/alembic/README deleted file mode 100644 index 98e4f9c..0000000 --- a/alembic/README +++ /dev/null @@ -1 +0,0 @@ -Generic single-database configuration. \ No newline at end of file diff --git a/bin/test.sh b/bin/test.sh index 5291f1d..fca767c 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -6,4 +6,4 @@ export FREENIT_ENV="test" setup -pytest -v -rs --ignore=freenit/project/ +pytest -v --ignore=freenit/project/ diff --git a/freenit/__init__.py b/freenit/__init__.py index 8966e1c..39774cf 100644 --- a/freenit/__init__.py +++ b/freenit/__init__.py @@ -1 +1 @@ -__version__ = "0.3.15" +__version__ = "0.3.16" diff --git a/freenit/cli.py b/freenit/cli.py index ea98fe3..bb815b3 100644 --- a/freenit/cli.py +++ b/freenit/cli.py @@ -1,13 +1,14 @@ import os import pathlib import subprocess - -from prompt_toolkit import prompt +import sys def main(): + if len(sys.argv) != 2: + raise ValueError(f"Usage: {sys.argv[0]}: ") + project_name = sys.argv[1] path = pathlib.Path(__file__).parent.resolve() - project_name = prompt("Name of the project: ") executable = f"{path}/../bin/freenit.sh" if not os.path.exists(executable): executable = f"{path}/bin/freenit.sh" diff --git a/freenit/models/ldap/group.py b/freenit/models/ldap/group.py index 3826be6..019b20a 100644 --- a/freenit/models/ldap/group.py +++ b/freenit/models/ldap/group.py @@ -50,7 +50,7 @@ async def get_all(cls, domain): client = get_client() try: async with client.connect(is_async=True) as conn: - dn = config.ldap.groupBase.format(domain) + dn = config.ldap.roleBase.format(domain) res = await conn.search(dn, LDAPSearchScope.SUB, f"(|{classes})") data = [] for gdata in res: diff --git a/migrate.py b/migrate.py index c508a1c..35e1e7f 100644 --- a/migrate.py +++ b/migrate.py @@ -8,8 +8,9 @@ def db_setup(): - importlib.import_module(f"{app_name}.app") + app = importlib.import_module(f"{app_name}.app") command.upgrade(alembic_cfg, "head") + return app if __name__ == "__main__": diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 4088045..0000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -asyncio_mode=auto diff --git a/tests/conftest.py b/tests/conftest.py index 06d9c09..79ece94 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,9 @@ -import importlib import os import pytest -from alembic import command from alembic.config import Config -from name import app_name +from migrate import db_setup as dbs from .client import Client @@ -16,8 +14,7 @@ @pytest.fixture def db_setup(): - app = importlib.import_module(f"{app_name}.app") - command.upgrade(alembic_cfg, "head") + app = dbs() yield app.app