Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use MSC_PYGEOAPI_OGC_API_URL for OpenAPI document #311

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ jobs:
- name: Install package 📦
run: python3 setup.py install
- name: run tests ⚙️
run: pytest -k test_loader
run: |
pytest -k test_loader
pytest tests/test_openapi_document.py
2 changes: 1 addition & 1 deletion debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
export MSC_PYGEOAPI_ES_TIMEOUT=90
export MSC_PYGEOAPI_ES_URL=http://localhost:9200
export MSC_PYGEOAPI_CACHEDIR=/tmp
export MSC_PYGEOAPI_OGC_API_URL=https://api.wxod-dev.cmc.ec.gc.ca/
export MSC_PYGEOAPI_OGC_API_URL=https://api.wxod-dev.cmc.ec.gc.ca
export MSC_PYGEOAPI_OGC_API_URL_BASEPATH=/
export MSC_PYGEOAPI_METPX_EVENT_FILE_PY=/opt/msc-pygeoapi/event/file_.py
export MSC_PYGEOAPI_METPX_EVENT_MESSAGE_PY=/opt/msc-pygeoapi/event/message.py
Expand Down
2,330 changes: 1,165 additions & 1,165 deletions deploy/default/msc-pygeoapi-openapi.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deploy/default/msc-pygeoapi.wsgi
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import os
os.environ['PYGEOAPI_CONFIG'] = '/opt/msc-pygeoapi/conf/msc-pygeoapi-config.yml'
os.environ['PYGEOAPI_OPENAPI'] = '/opt/msc-pygeoapi/conf/msc-pygeoapi-openapi.yml'
os.environ['MSC_PYGEOAPI_ES_URL'] = 'http://localhost:9200'
os.environ['MSC_PYGEOAPI_OGC_API_URL'] = 'https://api.wxod-dev.cmc.ec.gc.ca/'
os.environ['MSC_PYGEOAPI_OGC_API_URL'] = 'https://api.wxod-dev.cmc.ec.gc.ca'
os.environ['MSC_PYGEOAPI_OGC_API_URL_BASEPATH'] = '/'
os.environ['MSC_PYGEOAPI_LOCALE'] = '/opt/msc-pygeoapi/locale'
os.environ['MSC_PYGEOAPI_TEMPLATES'] = '/opt/msc-pygeoapi/theme/templates'
Expand Down
1 change: 0 additions & 1 deletion deploy/nightly/deploy-nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ mkdir schemas.opengis.net
curl -O http://schemas.opengis.net/SCHEMAS_OPENGIS_NET.zip && unzip ./SCHEMAS_OPENGIS_NET.zip "ogcapi/*" -d schemas.opengis.net && rm -f ./SCHEMAS_OPENGIS_NET.zip

cp msc-pygeoapi/deploy/default/msc-pygeoapi-config.yml msc-pygeoapi/deploy/nightly
sed -i "s#https://api.wxod-dev.cmc.ec.gc.ca/#$MSC_PYGEOAPI_OGC_API_URL#g" msc-pygeoapi/deploy/nightly/msc-pygeoapi-config.yml
sed -i 's#basepath: /#basepath: /msc-pygeoapi/nightly/latest#' msc-pygeoapi/deploy/nightly/msc-pygeoapi-config.yml
sed -i 's^# cors: true^cors: true^' msc-pygeoapi/deploy/nightly/msc-pygeoapi-config.yml

Expand Down
2 changes: 1 addition & 1 deletion deploy/nightly/msc-pygeoapi.wsgi
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import sys
os.environ['PYGEOAPI_CONFIG'] = '/data/web/msc-pygeoapi-nightly/latest/msc-pygeoapi/deploy/nightly/msc-pygeoapi-config.yml'
os.environ['PYGEOAPI_OPENAPI'] = '/data/web/msc-pygeoapi-nightly/latest/msc-pygeoapi/deploy/nightly/msc-pygeoapi-openapi.yml'
os.environ['MSC_PYGEOAPI_ES_URL'] = 'http://localhost:9200'
os.environ['MSC_PYGEOAPI_OGC_API_URL'] = 'https://geomet-dev-03-nightly.cmc.ec.gc.ca/msc-pygeoapi/nightly/latest/'
os.environ['MSC_PYGEOAPI_OGC_API_URL'] = 'https://geomet-dev-03-nightly.cmc.ec.gc.ca/msc-pygeoapi/nightly/latest'
os.environ['MSC_PYGEOAPI_OGC_API_URL_BASEPATH'] = '/'
os.environ['MSC_PYGEOAPI_TEMPLATES'] = '/data/web/msc-pygeoapi-nightly/latest/msc-pygeoapi/theme/templates'
os.environ['MSC_PYGEOAPI_STATIC'] = '/data/web/msc-pygeoapi-nightly/latest/msc-pygeoapi/theme/static'
Expand Down
2 changes: 1 addition & 1 deletion msc-pygeoapi.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export MSC_PYGEOAPI_ES_TIMEOUT=90
#export MSC_PYGEOAPI_ES_PASSWORD=bar
export MSC_PYGEOAPI_ES_URL=http://${MSC_PYGEOAPI_ES_USERNAME}:${MSC_PYGEOAPI_ES_PASSWORD}@localhost:9200
export MSC_PYGEOAPI_CACHEDIR=/tmp
export MSC_PYGEOAPI_OGC_API_URL=https://api.wxod-dev.cmc.ec.gc.ca/
export MSC_PYGEOAPI_OGC_API_URL=https://api.wxod-dev.cmc.ec.gc.ca
export MSC_PYGEOAPI_OGC_API_URL_BASEPATH=/
export MSC_PYGEOAPI_METPX_EVENT_FILE_PY=/opt/msc-pygeoapi/event/file_.py
export MSC_PYGEOAPI_METPX_EVENT_MESSAGE_PY=/opt/msc-pygeoapi/event/message.py
Expand Down
47 changes: 47 additions & 0 deletions tests/test_openapi_document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# =================================================================
#
# Author: Tom Kralidis <tom.kralidis@ec.gc.ca>
#
# Copyright (c) 2023 Tom Kralidis
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================

import pytest

from util import get_test_file_path


@pytest.fixture()
def openapi_config():
openapi_document = '../deploy/default/msc-pygeoapi-openapi.yml'
with open(get_test_file_path(openapi_document)) as fh:
return fh.read()


def test_openapi_config(openapi_config):
"""Test OpenAPI document"""

assert 'https://api.w' not in openapi_config
assert 'url: ${MSC_PYGEOAPI_OGC_API_URL}' in openapi_config
assert '$ref: ${MSC_PYGEOAPI_OGC_API_URL}' in openapi_config
Loading