def test_config_gets_cf_origin_from_env(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) monkeypatch.setenv("DEFAULT_CLOUDFRONT_ORIGIN", "foo") config = config_from_env() assert config.DEFAULT_CLOUDFRONT_ORIGIN == "foo"
def test_config_sets_ignore_duplicates_false_by_default( env, monkeypatch, mocked_env): monkeypatch.setenv("IGNORE_DUPLICATE_DOMAINS", "true") config = config_from_env() assert config.IGNORE_DUPLICATE_DOMAINS
def test_config_fixes_db_uri(env, monkeypatch, mocked_env, dburl_in): monkeypatch.setenv("FLASK_ENV", env) monkeypatch.setenv("DATABASE_URL", dburl_in) config = config_from_env() assert config.SQLALCHEMY_DATABASE_URI == "postgresql://mydb"
def test_config_uses_staging_acme_url(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) config = config_from_env() assert (config.ACME_DIRECTORY == "https://acme-staging-v02.api.letsencrypt.org/directory")
def test_config_gets_log_bucket_from_env(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) monkeypatch.setenv("CDN_LOG_BUCKET", "foo") config = config_from_env() assert config.CDN_LOG_BUCKET == "foo"
def test_config_parses_VCAP_SERVICES(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) config = config_from_env() assert config.REDIS_HOST == "my-redis-hostname" assert config.REDIS_PORT == "my-redis-port" assert config.REDIS_PASSWORD == "my-redis-password"
def test_config_uses_right_iam_prefix(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) config = config_from_env() assert ( config.IAM_SERVER_CERTIFICATE_PREFIX == f"/cloudfront/external-domains-{env}/" )
def test_config_provides_alb_arns(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) config = config_from_env() assert type(config.ALB_LISTENER_ARNS) == list assert config.ALB_LISTENER_ARNS == [ "arn:aws:elasticloadbalancing:us-east-2:123456789012:listener/app/my-load-balancer/1234567890123456" ]
def test_config_sets_smtp_variables(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) config = config_from_env() assert config.SMTP_FROM == "*****@*****.**" assert config.SMTP_USER == "*****@*****.**" assert config.SMTP_PASS == "this-password-is-invalid" assert config.SMTP_HOST == "127.0.0.1" assert config.SMTP_PORT == 1025 assert config.SMTP_CERT == "A_REAL_CERT_WOULD_BE_LONGER_THAN_THIS" assert config.SMTP_TO == "*****@*****.**"
from flask_migrate import Migrate from flask_sqlalchemy import SQLAlchemy from broker.config import config_from_env config = config_from_env() db = SQLAlchemy() migrate = Migrate()
def test_config_doesnt_explode(env, monkeypatch, mocked_env): monkeypatch.setenv("FLASK_ENV", env) config = config_from_env() assert env == config.FLASK_ENV