Skip to content

Commit

Permalink
Update test for empty env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
webb-ben committed Oct 1, 2024
1 parent 60a10de commit 718c3cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker/default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ server:
bind:
host: 0.0.0.0
port: 80
url: http://localhost:5000
url: ${PYGEAOPI_URL:-http://localhost:5000}
mimetype: application/json; charset=UTF-8
encoding: utf-8
gzip: false
Expand Down
2 changes: 2 additions & 0 deletions tests/pygeoapi-test-config-envvars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ server:
map:
url: https://tile.openstreetmap.org/{z}/{x}/{y}.png
attribution: '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
api_rules: # optional API design rules to which pygeoapi should adhere
url_prefix: ${PYGEOAPI_PREFIX:-}

logging:
level: DEBUG
Expand Down
3 changes: 3 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ def test_config_envvars():
assert config['server']['url'] == 'http://localhost:5000/'
assert config['metadata']['identification']['title'] == \
'pygeoapi default instance my title'
assert config['server']['api_rules']['url_prefix'] == ''

os.environ['PYGEOAPI_URL'] = 'https://localhost:5000'
os.environ['PYGEOAPI_PREFIX'] = 'v1'

with open(get_test_file_path('pygeoapi-test-config-envvars.yml')) as fh:
config = yaml_load(fh)

assert config['server']['url'] == 'https://localhost:5000'
assert config['server']['api_rules']['url_prefix'] == 'v1'

os.environ.pop('PYGEOAPI_PORT')

Expand Down

0 comments on commit 718c3cf

Please sign in to comment.