|
| 1 | +def test_runtime_environment__default(settings): |
| 2 | + assert settings.RUNTIME_ENVIRONMENT() == "dev" |
| 3 | + |
| 4 | + |
| 5 | +def test_runtime_environment__dev(settings): |
| 6 | + settings.ALLOWED_HOSTS = ["dev-benefits.calitp.org"] |
| 7 | + assert settings.RUNTIME_ENVIRONMENT() == "dev" |
| 8 | + |
| 9 | + |
| 10 | +def test_runtime_environment__local(settings): |
| 11 | + settings.ALLOWED_HOSTS = ["localhost", "127.0.0.1"] |
| 12 | + assert settings.RUNTIME_ENVIRONMENT() == "dev" |
| 13 | + |
| 14 | + |
| 15 | +def test_runtime_environment__nonmatching(settings): |
| 16 | + # with only nonmatching hosts, return dev |
| 17 | + settings.ALLOWED_HOSTS = ["example.com", "example2.org"] |
| 18 | + assert settings.RUNTIME_ENVIRONMENT() == "dev" |
| 19 | + |
| 20 | + |
| 21 | +def test_runtime_environment__test(settings): |
| 22 | + settings.ALLOWED_HOSTS = ["test-benefits.calitp.org"] |
| 23 | + assert settings.RUNTIME_ENVIRONMENT() == "test" |
| 24 | + |
| 25 | + |
| 26 | +def test_runtime_environment__test_and_nonmatching(settings): |
| 27 | + # when test is specified with other nonmatching hosts, assume test |
| 28 | + settings.ALLOWED_HOSTS = ["test-benefits.calitp.org", "example.com"] |
| 29 | + assert settings.RUNTIME_ENVIRONMENT() == "test" |
| 30 | + |
| 31 | + |
| 32 | +def test_runtime_environment__test_and_prod(settings): |
| 33 | + # if both test and prod are specified (edge case/error in configuration), assume test |
| 34 | + settings.ALLOWED_HOSTS = ["benefits.calitp.org", "test-benefits.calitp.org"] |
| 35 | + assert settings.RUNTIME_ENVIRONMENT() == "test" |
| 36 | + |
| 37 | + |
| 38 | +def test_runtime_environment__prod(settings): |
| 39 | + settings.ALLOWED_HOSTS = ["benefits.calitp.org"] |
| 40 | + assert settings.RUNTIME_ENVIRONMENT() == "prod" |
| 41 | + |
| 42 | + |
| 43 | +def test_runtime_environment__prod_and_nonmatching(settings): |
| 44 | + # when prod is specified with other nonmatching hosts, assume prod |
| 45 | + settings.ALLOWED_HOSTS = ["benefits.calitp.org", "https://example.com"] |
| 46 | + assert settings.RUNTIME_ENVIRONMENT() == "prod" |
0 commit comments