Skip to content

Commit

Permalink
urnresolver (#13): Added URNResolver test files
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Mar 7, 2021
1 parent ad3a6a0 commit aed3208
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 9 deletions.
41 changes: 32 additions & 9 deletions hxlm/core/bin/urnresolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ def make_args_urnresolver(self):
"Resource Name (URI) to Uniform Resource " +
"Identifier (URI)"))

parser.add_argument(
'--debug',
help='instead of return the result, do full debug',
action='store_const',
const=True,
default=False
)

parser.add_argument(
'--config',
help='instead of return the result, do full debug',
metavar='config_file',
type=str,
# action='store_const',
# const=True,
default=False
)

self.args = parser.parse_args()
return self.args

Expand All @@ -127,17 +145,22 @@ def execute_cli(self, args,
called will convert the HXL source to example format.
"""

# print('args', args)
urn_item = HUrn.cast_urn(urn=args.infile)
urn_item.prepare()
# valt = HUrnUtil.get_urn_vault_local_info('un', 'locode')
HUrnUtil.debug_local_data('un', 'locode')
HUrnUtil.get_urn_vault_local_info(urn_item)

# print('valt', valt)
print(args.infile, urn_item)
print('about', urn_item.about())
print('about base_paths', urn_item.about('base_paths'))
print('about object_names', urn_item.about('object_names'))

if 'debug' in args and args.debug:
# valt = HUrnUtil.get_urn_vault_local_info('un', 'locode')
HUrnUtil.debug_local_data('un', 'locode')
HUrnUtil.get_urn_vault_local_info(urn_item)

# print('valt', valt)
print(args.infile, urn_item)
print('about', urn_item.about())
print('about base_paths', urn_item.about('base_paths'))
print('about object_names', urn_item.about('object_names'))

print(urn_item.get_resources())

# print('args', args)
# print('args', args)
Expand Down
3 changes: 3 additions & 0 deletions tests/urnresolver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# tests/urnresolver
The test files on this directory are used when you want to explicitly enforce
an exact match of an URN in offline mode.
4 changes: 4 additions & 0 deletions tests/urnresolver/csv/urnresolver.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"#item+urn","#x_source"
"urn:data:xz:hxl:std:core:hashtag","https://docs.google.com/spreadsheets/d/1En9FlmM8PrbTWgl3UHPF_MXnJ6ziVZFhBbojSJzBdLI/pub?gid=319251406&single=true&output=csv"
"urn:data:xz:hxl:std:core:attribute","https://docs.google.com/spreadsheets/d/1En9FlmM8PrbTWgl3UHPF_MXnJ6ziVZFhBbojSJzBdLI/pub?gid=1810309357&single=true&output=csv"
"urn:data:xz:hxlcplp:fod:lang","https://proxy.hxlstandard.org/data.csv?dest=data_view&url=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F12k4BWqq5c3mV9ihQscPIwtuDa_QRB-iFohO7dXSSptI%2Fedit%23gid%3D0"
20 changes: 20 additions & 0 deletions tests/urnresolver/json/urnresolver.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"urn": "urn:data:xz:hxl:std:core:hashtag",
"source": [
"https://docs.google.com/spreadsheets/d/1En9FlmM8PrbTWgl3UHPF_MXnJ6ziVZFhBbojSJzBdLI/pub?gid=319251406&single=true&output=csv"
]
},
{
"urn": "urn:data:xz:hxl:std:core:attribute",
"source": [
"https://docs.google.com/spreadsheets/d/1En9FlmM8PrbTWgl3UHPF_MXnJ6ziVZFhBbojSJzBdLI/pub?gid=1810309357&single=true&output=csv"
]
},
{
"urn": "urn:data:xz:hxlcplp:fod:lang",
"source": [
"https://proxy.hxlstandard.org/data.csv?dest=data_view&url=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F12k4BWqq5c3mV9ihQscPIwtuDa_QRB-iFohO7dXSSptI%2Fedit%23gid%3D0"
]
}
]
16 changes: 16 additions & 0 deletions tests/urnresolver/yaml/urnresolver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

# TODO: when URNResolver start to undestand CKAN instances, also put as
# extra source CKAN instead of direct access Gooogle Drive
# (Emerson Rocha, 2021-03-06 20:01 UTC)

# https://data.humdata.org/dataset/hxl-core-schemas
- urn: "urn:data:xz:hxl:std:core:hashtag"
source:
- https://docs.google.com/spreadsheets/d/1En9FlmM8PrbTWgl3UHPF_MXnJ6ziVZFhBbojSJzBdLI/pub?gid=319251406&single=true&output=csv
- urn: "urn:data:xz:hxl:std:core:attribute"
source:
- https://docs.google.com/spreadsheets/d/1En9FlmM8PrbTWgl3UHPF_MXnJ6ziVZFhBbojSJzBdLI/pub?gid=1810309357&single=true&output=csv
- urn: "urn:data:xz:hxlcplp:fod:lang"
source:
- https://proxy.hxlstandard.org/data.csv?dest=data_view&url=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F12k4BWqq5c3mV9ihQscPIwtuDa_QRB-iFohO7dXSSptI%2Fedit%23gid%3D0

0 comments on commit aed3208

Please sign in to comment.