forked from nasa/harmony-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_config.py
80 lines (58 loc) · 2.29 KB
/
test_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import pytest
from harmony.config import Config, Environment
def test_config_from_env(mocker):
expected_value = 'bar'
mocker.patch('harmony.config.os.getenv', return_value=expected_value)
config = Config()
assert config.FOO == expected_value
def test_config_not_there():
config = Config()
assert config.ASDF is None
def test_config_built_in():
config = Config()
assert config.NUM_REQUESTS_WORKERS is not None
@pytest.mark.parametrize('env,url', [
(Environment.LOCAL, 'localhost'),
(Environment.SIT, 'harmony.sit.earthdata.nasa.gov'),
(Environment.UAT, 'harmony.uat.earthdata.nasa.gov'),
(Environment.PROD, 'harmony.earthdata.nasa.gov')
])
def test_harmony_hostname_matches_environment(env, url):
config = Config(env)
assert config.harmony_hostname == url
@pytest.mark.parametrize('env,url', [
(Environment.LOCAL, 'http'),
(Environment.SIT, 'https'),
(Environment.UAT, 'https'),
(Environment.PROD, 'https')
])
def test_url_scheme_matches_environment(env, url):
config = Config(env)
assert config.url_scheme == url
@pytest.mark.parametrize('env,url', [
(Environment.LOCAL, 'http://localhost:3000'),
(Environment.SIT, 'https://harmony.sit.earthdata.nasa.gov'),
(Environment.UAT, 'https://harmony.uat.earthdata.nasa.gov'),
(Environment.PROD, 'https://harmony.earthdata.nasa.gov')
])
def test_root_url_matches_environment(env, url):
config = Config(env)
assert config.root_url == url
@pytest.mark.parametrize('env,url', [
(Environment.LOCAL, 'http://localhost:9999'),
(Environment.SIT, 'https://harmony.sit.earthdata.nasa.gov'),
(Environment.UAT, 'https://harmony.uat.earthdata.nasa.gov'),
(Environment.PROD, 'https://harmony.earthdata.nasa.gov')
])
def test_localhost_port_is_overridable(env, url):
config = Config(env, localhost_port=9999)
assert config.root_url == url
@pytest.mark.parametrize('env,url', [
(Environment.LOCAL, 'http://localhost:3000/jobs'),
(Environment.SIT, 'https://harmony.sit.earthdata.nasa.gov/jobs'),
(Environment.UAT, 'https://harmony.uat.earthdata.nasa.gov/jobs'),
(Environment.PROD, 'https://harmony.earthdata.nasa.gov/jobs')
])
def test_edl_validation_url_matches_environment(env, url):
config = Config(env)
assert config.edl_validation_url == url