mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 07:13:55 +02:00
Add a cli interface to choose a configuration (#163)
- [x] add a cli to the webserver to take env variables into account - [x] add a cli to the data processing that takes enviromental variable as a valid source into account - [x] rework the cli for the reset sql command - [x] rework the cli for the copying of sql data from one db to another
This commit is contained in:
34
tests/config/config_template_test.py
Normal file
34
tests/config/config_template_test.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""Test for config templates."""
|
||||
from aki_prj23_transparenzregister.config.config_template import (
|
||||
MongoConnection,
|
||||
SQLiteConnectionString,
|
||||
)
|
||||
|
||||
|
||||
def test_sqlite_connection_string() -> None:
|
||||
"""Tests if the sqlite protocol is correctly added to a path."""
|
||||
assert str(SQLiteConnectionString("some-path-to.db")) == "sqlite:///some-path-to.db"
|
||||
assert (
|
||||
str(SQLiteConnectionString("other-path-to.db")) == "sqlite:///other-path-to.db"
|
||||
)
|
||||
assert SQLiteConnectionString("some-path-to.db") == SQLiteConnectionString(
|
||||
"some-path-to.db"
|
||||
)
|
||||
|
||||
|
||||
def test_get_conn_string_no_credentials() -> None:
|
||||
"""Tests the mongo connection string generation."""
|
||||
conn = MongoConnection("localhost", "", 27017, None, None)
|
||||
assert conn.get_conn_string() == "mongodb://localhost:27017"
|
||||
|
||||
|
||||
def test_get_conn_string_no_port_but_credentials() -> None:
|
||||
"""Tests the mongo connection string generation."""
|
||||
conn = MongoConnection("localhost", "", None, "admin", "password")
|
||||
assert conn.get_conn_string() == "mongodb+srv://admin:password@localhost"
|
||||
|
||||
|
||||
def test_get_conn_simple() -> None:
|
||||
"""Tests the mongo connection string generation."""
|
||||
conn = MongoConnection("localhost", "", None, None, None)
|
||||
assert conn.get_conn_string() == "mongodb+srv://localhost"
|
Reference in New Issue
Block a user