Skip to content
Snippets Groups Projects
Unverified Commit cadc1a51 authored by Pavel Kirilin's avatar Pavel Kirilin :alien:
Browse files

Updated generation.


Signed-off-by: default avatarPavel Kirilin <win10@list.ru>
parent ad5c7d25
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,9 @@ import shutil
import subprocess
import sys
import yaml
import json
MANIFEST = "conditional_files.yaml"
MANIFEST = "conditional_files.json"
FIRST_RUN_WIN = "first_run.bat"
FIRST_RUN = "first_run.sh"
......@@ -22,7 +22,7 @@ def delete_resource(resource):
def delete_resources_for_disabled_features():
with open(MANIFEST) as manifest_file:
manifest = yaml.safe_load(manifest_file)
manifest = json.load(manifest_file)
for feature in manifest['features']:
if not feature['enabled']:
print("removing resources for disabled feature {}...".format(feature['name']))
......
......@@ -35,6 +35,7 @@ repos:
- "--pretty"
- "--show-error-codes"
- "--no-warn-return-any"
- "--implicit-reexport"
- "--allow-untyped-decorators"
exclude: >
(?x)^(
......
{
"features": [
{
"name": "Redis support",
"enabled": {{cookiecutter.add_redis|lower}},
"resources": [
"src/services/redis.py",
"src/api/redis_api"
]
},
{
"name": "Systemd support",
"enabled": {{cookiecutter.add_systemd|lower}},
"resources": [
"systemd"
]
},
{
"name": "Dummy DB model",
"enabled": {{cookiecutter.add_dummy_model|lower}},
"resources": [
"src/models/dummy_db_model.py",
"migrations/versions/7ae297ab5ac1_created_dummy_model.py",
"tests/dummy_db_test.py",
"src/api/dummy_db"
]
}
]
}
\ No newline at end of file
features:
- name: Redis support
enabled: {{cookiecutter.add_redis|lower}}
resources:
- src/services/redis.py
- src/api/redis_api
- name: Systemd support
enabled: {{cookiecutter.add_systemd|lower}}
resources:
- systemd
- name: Dummy DB model
enabled: {{cookiecutter.add_dummy_model|lower}}
resources:
- src/models/dummy_db_model.py
- migrations/versions/7ae297ab5ac1_created_dummy_model.py
- tests/dummy_db_test.py
- src/api/dummy_db
\ No newline at end of file
......@@ -13,18 +13,15 @@ from src.services.redis import redis
{% endif %}
from src.settings import Settings, settings
config = {
"handlers": [
{
"sink": sys.stderr,
"backtrace": False,
"diagnose": settings.is_dev,
"catch": False,
"colorize": settings.is_dev,
},
]
}
logger.configure(**config)
logger.configure(
handlers=[{
"sink": sys.stderr,
"backtrace": False,
"diagnose": settings.is_dev,
"catch": False,
"colorize": settings.is_dev,
}]
)
app = FastAPI(
title="{{cookiecutter.project_name}}",
......
......@@ -5,7 +5,7 @@ import alembic.config
import pytest
from fastapi.testclient import TestClient
from sqlalchemy import create_engine
from sqlalchemy.engine import Connection
from sqlalchemy.engine import Connection, Engine
from sqlalchemy.engine.url import URL, make_url
from sqlalchemy.exc import ProgrammingError
......@@ -15,7 +15,7 @@ from src.settings import settings
warnings.filterwarnings("ignore", category=DeprecationWarning)
def get_engine():
def get_engine() -> Engine:
pg_db_url = make_url(
URL(
drivername=settings.db_driver,
......@@ -30,7 +30,7 @@ def get_engine():
return engine
def run_psql_without_transaction(command: str):
def run_psql_without_transaction(command: str) -> None:
engine = get_engine()
connection = engine.connect()
connection.connection.set_isolation_level(0)
......@@ -40,7 +40,7 @@ def run_psql_without_transaction(command: str):
@pytest.fixture(scope="session")
def create_database():
def create_database() -> None:
try:
run_psql_without_transaction(f"CREATE DATABASE {settings.postgres_db}")
except ProgrammingError:
......
......@@ -25,7 +25,7 @@ def test_delete_dummy_obj(
) -> None:
with app_fixture as client:
put_result = client.put(
f"/dummy_db_obj/",
"/dummy_db_obj/",
json=test_conf.request_data["json"],
)
assert put_result.status_code == 200
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment