You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
from iti.config import BaseConfig, TestConfig as FrameworkTestConfig, default_mysql_url
|
|
|
|
|
|
def test_default_mysql_url_uses_mysql_driver(monkeypatch):
|
|
monkeypatch.setenv("MYSQL_USER", "u")
|
|
monkeypatch.setenv("MYSQL_PASSWORD", "p")
|
|
monkeypatch.setenv("MYSQL_HOST", "db")
|
|
monkeypatch.setenv("MYSQL_PORT", "3307")
|
|
|
|
assert default_mysql_url("iti_test") == (
|
|
"mysql+pymysql://u:p@db:3307/iti_test?charset=utf8mb4"
|
|
)
|
|
|
|
|
|
def test_test_config_default_database_is_mysql(monkeypatch):
|
|
monkeypatch.delenv("DATABASE_URL", raising=False)
|
|
monkeypatch.setenv("MYSQL_DATABASE", "iti_test")
|
|
|
|
config = FrameworkTestConfig()
|
|
|
|
assert config.database_url.startswith("mysql+pymysql://")
|
|
assert config.testing is True
|
|
assert config.ratelimit_enabled is False
|
|
|
|
|
|
def test_base_config_can_be_overridden_for_unit_tests():
|
|
config = BaseConfig(database_url="sqlite+pysqlite:///:memory:", testing=True)
|
|
|
|
assert config.database_url == "sqlite+pysqlite:///:memory:"
|
|
assert config.testing is True
|