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

add CAP test #767

Merged
merged 12 commits into from
Sep 12, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/tests-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ jobs:
python3 wis2box-ctl.py execute wis2box auth add-token -p wis2downloader github123 -y
echo '{"topic": "origin/a/wis2/+/data/core/#"}' > test.json
curl -X POST http://localhost/wis2downloader/subscriptions -H "Content-Type: application/json" -H "Authorization: Bearer github123" -d @test.json
- name: add CAP data, cap-publish
env:
DISCOVERY_METADATA: /data/wis2box/metadata/discovery/int-wmo-test-cap.yml
DISCOVERY_METADATA_ID: urn:wmo:md:int-wmo-test:cap
run: |
python3 wis2box-ctl.py execute wis2box dataset publish $DISCOVERY_METADATA
curl -s http://localhost/data/metadata/$DISCOVERY_METADATA_ID.json --output /tmp/$DISCOVERY_METADATA_ID
pywcmp ets validate /tmp/$DISCOVERY_METADATA_ID
python3 tests/send_CAP_as_message.py
- name: add Malawi synop data (csv2bufr synop_bufr template) 🇲🇼
env:
TOPIC_HIERARCHY: origin/a/wis2/mw-mw_met_centre-test/data/core/weather/surface-based-observations/synop
Expand Down
71 changes: 71 additions & 0 deletions tests/data/CAP/cap_example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml-stylesheet type="text/xsl" href="https://www.meteo.sc/cap-alert-style.xsl"?>
<alert xmlns="urn:oasis:names:tc:emergency:cap:1.2">
<identifier>urn:oid:2.49.0.0.690.0.2024.5.19.13.18.0</identifier>
<sender>info@meteo.gov.sc</sender>
<sent>2024-05-19T17:18:00+04:00</sent>
<status>Actual</status>
<msgType>Alert</msgType>
<scope>Public</scope>
<info>
<language>en</language>
<category>Met</category>
<event>Strong Winds</event>
<urgency>Immediate</urgency>
<severity>Moderate</severity>
<certainty>Observed</certainty>
<audience>General Public</audience>
<effective>2024-05-19T17:30:00+04:00</effective>
<onset>2024-05-19T17:30:00+04:00</onset>
<expires>2024-05-19T23:30:00+04:00</expires>
<senderName>Seychelles Meteorological Authority</senderName>
<headline>Moderate to strong south-easterly winds over Aldabra area</headline>
<description>Moderate to strong south-easterly winds over Aldabra area associated with a severe tropical storm Ialy on 19th May 2024 from 5pm to 11pm</description>
<instruction>Beware of strong south-easterly winds of 40km/hr gusting to 60km/hr causing rough seas. Mariners are advised to take extra precautions when navigating these areas</instruction>
<web>https://www.meteo.sc/alerts/severe-tropical-storm-ialy-is-expected-to-cause-moderate-to-strong-south-easterly-winds-over-aldabra-area-on-19th-may-2024/</web>
<contact>info@meteo.gov.sc</contact>
<area>
<areaDesc>Aldabra area</areaDesc>
<polygon>-9.186965,46.078276 -9.336746,45.936002 -9.57065,45.983427 -9.748309,46.116216 -9.897844,46.249006 -10.000609,46.42922 -9.953902,46.694799 -9.692216,46.770679 -9.467752,46.770679 -9.327387,46.742224 -9.186965,46.694799 -9.140146,46.533555 -9.121416,46.362825 -9.186965,46.078276</polygon>
</area>
</info>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2006/12/xml-c14n11"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"/>
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2006/12/xml-c14n11"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>s9RKcAph3khD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7VSVL7UvffuEPOsY+PvoongycjZpQB1AEiw42vapkc0D+VqAvqd
MOscUgHLVt0sgdm7v6s52IRzAAABkHNmvkUAAAQDAEYwRAIgFtFOST10XUPf2BYT
xBBvHVqU98eB2hwQtgVJ4hJP5RoCIF0wDotvI7r+kamXqgvee+/ig4NP2ZbqaLP6
a2/T5cjnMAoGCCqGSM49BAMDA2kAMGYCMQCyLgDsI/yPYKkI1zM3zs0w7iI23MfZ
BGuNKUUa7qHLR1O6eNnEmrSH24bdzXdacRoCMQCLW6bf0Y1mwuJN+jBCjTbyCe+F
1ZEDJBb2AKxTZpWdVdtfRErY5BxHuACOm9SlXGE=
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
</alert>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ identification:
keywords_type: theme
vocabulary:
name: Earth system disciplines as defined by the WMO Unified Data Policy, Resolution 1 (Cg-Ext(2021), Annex 1.
url: https://codes.wmo.int/topic-hierarchy/earth-system-discipline
url: https://codes.wmo.int/wis/topic-hierarchy/earth-system-discipline
extents:
spatial:
- bbox: [11.0937728207,-5.03798674888,18.4530652198,3.72819651938]
Expand Down
21 changes: 11 additions & 10 deletions tests/data/metadata/discovery/int-wmo-test-cap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mcf:
version: 1.0

metadata:
identifier: urn:wmo:md:int_wmo_test:cap
identifier: urn:wmo:md:int-wmo-test:cap
hierarchylevel: dataset

identification:
Expand All @@ -32,10 +32,10 @@ identification:
wmo:
keywords:
- weather
keywords_type: themes
keywords_type: theme
vocabulary:
name: Earth system disciplines as defined by the WMO Unified Data Policy, Resolution 1 (Cg-Ext(2021), Annex 1.
url: https://codes.wmo.int/topic-hierarchy/earth-system-discipline
url: https://codes.wmo.int/wis/topic-hierarchy/earth-system-discipline
extents:
spatial:
- bbox: [-180.0, -90.0, 180.0, 90.0]
Expand All @@ -44,12 +44,13 @@ identification:
- begin: 2024-07-02
end: null
resolution: P1H
wmo_data_policy: core
rights: WMO Unified Policy for the International Exchange of Earth System Data
url: https://example.org/fixme

contact:
host:
organization: WMO
url: https://wmo.int
host: &contact_poc
organization: World Meteorological Organisation
url: https://www.wmo.int/
individualname: Firstname Lastname
positionname: Position Name
phone: null
Expand All @@ -58,7 +59,7 @@ contact:
city: null
administrativearea: null
postalcode: null
country: Switzerland
email: you@example.com
hoursofservice: 0700h - 1500h UTC
country: null
email: null
hoursofservice: 0800h - 1600h UTC
contactinstructions: email
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ identification:
keywords_type: theme
vocabulary:
name: Earth system disciplines as defined by the WMO Unified Data Policy, Resolution 1 (Cg-Ext(2021), Annex 1.
url: https://github.com/wmo-im/wis2-topic-hierarchy/blob/main/topic-hierarchy/earth-system-discipline/index.csv
url: https://codes.wmo.int/wis/topic-hierarchy/earth-system-discipline
extents:
spatial:
- bbox: [-180.0, -90.0, 180.0, 90.0]
Expand Down
2 changes: 1 addition & 1 deletion tests/data/metadata/discovery/int-wmo-test-ship-hourly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ identification:
keywords_type: theme
vocabulary:
name: Earth system disciplines as defined by the WMO Unified Data Policy, Resolution 1 (Cg-Ext(2021), Annex 1.
url: https://github.com/wmo-im/wis2-topic-hierarchy/blob/main/topic-hierarchy/earth-system-discipline/index.csv
url: https://codes.wmo.int/wis/topic-hierarchy/earth-system-discipline
extents:
spatial:
- bbox: [-180.0, -90.0, 180.0, 90.0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ identification:
keywords_type: theme
vocabulary:
name: Earth system disciplines as defined by the WMO Unified Data Policy, Resolution 1 (Cg-Ext(2021), Annex 1.
url: https://github.com/wmo-im/wis2-topic-hierarchy/blob/main/topic-hierarchy/earth-system-discipline/index.csv
url: https://codes.wmo.int/wis/topic-hierarchy/earth-system-discipline
extents:
spatial:
- bbox: [-180.0, -90.0, 180.0, 90.0]
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def test_wis2downloader():
'origin/a/wis2/int-wmo-test/data/core/ocean/surface-based-observations/drifting-buoys': 2, # noqa
'origin/a/wis2/int-wmo-test/data/core/weather/surface-based-observations/wind-profile': 1, # noqa
'origin/a/wis2/int-wmo-test/data/core/weather/surface-based-observations/ship-hourly': 5, # noqa
'origin/a/wis2/it-meteoam/data/core/weather/surface-based-observations/synop': 31 # noqa
'origin/a/wis2/it-meteoam/data/core/weather/surface-based-observations/synop': 31, # noqa
'origin/a/wis2/int-wmo-test/data/core/weather/advisories-warnings': 1 # noqa
}

topic_nfiles_dict_found = {}
Expand Down Expand Up @@ -125,7 +126,7 @@ def test_metadata_discovery_publish():
"""Test discovery metadata publishing"""

r = SESSION.get(f'{API_URL}/collections/discovery-metadata/items').json()
assert r['numberMatched'] == 9
assert r['numberMatched'] == 10

r = SESSION.get(f'{API_URL}/collections/discovery-metadata/items/{ID}').json() # noqa

Expand Down Expand Up @@ -302,7 +303,7 @@ def test_message_api():
'dz-meteoalgerie': 29,
'ro-rnimh': 50,
'cg-met': 15,
'int-wmo': 11,
'int-wmo': 13,
'cn-cma': 11
}
for key, value in counts.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
BROKER_HOST = 'localhost'
BROKER_PORT = '1883'

filename = 'tests/data/cap/sc_example.xml'
filename = 'tests/data/CAP/cap_example.xml'

# create a message containing the CAP alert in
# the data field as base64 encoded bytes
with open(filename, 'rb') as file:
data = base64.b64encode(file.read()).decode()

msg = {
'metadata_id': 'urn:wmo:md:int_wmo_test:cap',
'metadata_id': 'urn:wmo:md:int-wmo-test:cap',
'data': data,
'filename': filename.split('/')[-1]
}
Expand Down