Add an ORM layer
- use SQLAlchemy (and PostgreSQL) to model the ORM layer
- add the following models:
+ Address => modelling all kinds of addresses
+ City => model the three target cities
+ Courier => model the UDP's couriers
+ Customer => model the UDP's customers
+ Order => model the orders received by the UDP
+ Restaurant => model the restaurants active on the UDP
- so far, the emphasis lies on expression the Foreign Key
and Check Constraints that are used to validate the assumptions
inherent to the cleanded data
- provide database-independent unit tests with 100% coverage
- provide additional integration tests ("e2e") that commit data to
a PostgreSQL instance to validate that the constraints work
- adapt linting rules a bit
This commit is contained in:
parent
d219fa816d
commit
fdcc93a1ea
24 changed files with 2119 additions and 4 deletions
|
|
@ -6,9 +6,10 @@ via the `config` proxy at the package's top level.
|
|||
That already loads the correct configuration
|
||||
depending on the current environment.
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import warnings
|
||||
|
||||
import dotenv
|
||||
|
|
@ -17,6 +18,13 @@ import dotenv
|
|||
dotenv.load_dotenv()
|
||||
|
||||
|
||||
def random_schema_name() -> str:
|
||||
"""Generate a random PostgreSQL schema name for testing."""
|
||||
return ''.join(
|
||||
random.choice(string.ascii_lowercase) for _ in range(10) # noqa:S311
|
||||
)
|
||||
|
||||
|
||||
class Config:
|
||||
"""Configuration that applies in all situations."""
|
||||
|
||||
|
|
@ -57,7 +65,7 @@ class TestingConfig(Config):
|
|||
TESTING = True
|
||||
|
||||
DATABASE_URI = os.getenv('DATABASE_URI_TESTING') or Config.DATABASE_URI
|
||||
CLEAN_SCHEMA = os.getenv('CLEAN_SCHEMA_TESTING') or Config.CLEAN_SCHEMA
|
||||
CLEAN_SCHEMA = os.getenv('CLEAN_SCHEMA_TESTING') or random_schema_name()
|
||||
|
||||
|
||||
def get_config(env: str = 'production') -> Config:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue