2021-01-02 19:28:03 +01:00
|
|
|
from flask import Flask
|
2019-11-13 18:40:01 +01:00
|
|
|
|
2022-04-02 17:16:10 +02:00
|
|
|
from fittrackee import VERSION
|
2021-01-20 16:47:00 +01:00
|
|
|
from fittrackee.application.models import AppConfig
|
2022-04-02 17:16:10 +02:00
|
|
|
from fittrackee.users.models import User
|
2021-01-20 16:47:00 +01:00
|
|
|
|
2019-11-13 18:40:01 +01:00
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
class TestConfigModel:
|
2021-01-02 19:28:03 +01:00
|
|
|
def test_application_config(self, app: Flask) -> None:
|
2020-05-10 15:55:56 +02:00
|
|
|
app_config = AppConfig.query.first()
|
2022-04-02 17:16:10 +02:00
|
|
|
app_config.admin_contact = 'admin@example.com'
|
|
|
|
|
|
|
|
assert app_config.is_registration_enabled is True
|
|
|
|
assert (
|
|
|
|
app_config.map_attribution
|
|
|
|
== app.config['TILE_SERVER']['ATTRIBUTION']
|
|
|
|
)
|
2019-11-13 18:40:01 +01:00
|
|
|
|
2020-05-10 15:55:56 +02:00
|
|
|
serialized_app_config = app_config.serialize()
|
2022-04-02 17:16:10 +02:00
|
|
|
assert (
|
|
|
|
serialized_app_config['admin_contact'] == app_config.admin_contact
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
serialized_app_config['gpx_limit_import']
|
|
|
|
== app_config.gpx_limit_import
|
|
|
|
)
|
2022-04-23 18:04:20 +02:00
|
|
|
assert serialized_app_config['is_email_sending_enabled'] is True
|
2020-05-10 15:55:56 +02:00
|
|
|
assert serialized_app_config['is_registration_enabled'] is True
|
2022-04-02 17:16:10 +02:00
|
|
|
assert (
|
|
|
|
serialized_app_config['max_single_file_size']
|
|
|
|
== app_config.max_single_file_size
|
|
|
|
)
|
|
|
|
assert (
|
|
|
|
serialized_app_config['max_zip_file_size']
|
|
|
|
== app_config.max_zip_file_size
|
2020-09-16 13:01:15 +02:00
|
|
|
)
|
2022-04-02 17:16:10 +02:00
|
|
|
assert serialized_app_config['max_users'] == app_config.max_users
|
|
|
|
assert (
|
|
|
|
serialized_app_config['map_attribution']
|
|
|
|
== app_config.map_attribution
|
|
|
|
)
|
|
|
|
assert serialized_app_config['version'] == VERSION
|
|
|
|
|
|
|
|
def test_it_returns_registration_disabled_when_users_count_exceeds_limit(
|
|
|
|
self, app: Flask, user_1: User, user_2: User
|
|
|
|
) -> None:
|
|
|
|
app_config = AppConfig.query.first()
|
|
|
|
app_config.max_users = 2
|
|
|
|
serialized_app_config = app_config.serialize()
|
|
|
|
|
|
|
|
assert app_config.is_registration_enabled is False
|
|
|
|
assert serialized_app_config['is_registration_enabled'] is False
|
2022-04-23 18:04:20 +02:00
|
|
|
|
|
|
|
def test_it_returns_email_sending_disabled_when_no_email_url_provided(
|
|
|
|
self, app_wo_email_activation: Flask, user_1: User, user_2: User
|
|
|
|
) -> None:
|
|
|
|
app_config = AppConfig.query.first()
|
|
|
|
serialized_app_config = app_config.serialize()
|
|
|
|
|
|
|
|
assert serialized_app_config['is_email_sending_enabled'] is False
|