Skip to content

Commit

Permalink
Merge pull request #135 from GSA/numerical-titles-are-ok
Browse files Browse the repository at this point in the history
Numerical titles are ok
  • Loading branch information
nickumia-reisys authored Jan 30, 2023
2 parents 59e595a + 687e8b4 commit 010aa45
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ckanext/datajson/datajson.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ def import_stage(self, harvest_object):
return True

dataset = json.loads(harvest_object.content)
# Ensure title is a string for munging/manipulation
# https://github.com/GSA/data.gov/issues/4172
dataset['title'] = str(dataset['title'])
schema_version = '1.0' # default to '1.0'
is_collection = False
parent_pkg_id = ''
Expand Down
43 changes: 43 additions & 0 deletions ckanext/datajson/tests/datajson-samples/numerical-title.data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"@type": "dcat:Catalog",
"describedBy": "https://project-open-data.cio.gov/v1.1/schema/catalog.json",
"conformsTo": "https://project-open-data.cio.gov/v1.1/schema",
"@context": "https://project-open-data.cio.gov/v1.1/schema/catalog.jsonld",
"dataset": [
{
"identifier": "null-spatial",
"accessLevel": "public",
"contactPoint": {
"hasEmail": "mailto:[email protected]",
"@type": "vcard:Contact",
"fn": "Nicole Numbi"
},
"programCode": [
"005:059"
],
"description": "Sample dataset. Spatial can be null",
"title": 707,
"distribution": [
{
"@type": "dcat:Distribution",
"downloadURL": "http://www.dm.usda.gov/foia/docs/Copy%20of%20ECM%20Congressional%20Logs%20FY14.xls",
"mediaType": "application/vnd.ms-excel",
"title": "Congressional Logs for Fiscal Year 2014"
}
],
"license": "https://creativecommons.org/publicdomain/zero/1.0/",
"bureauCode": [
"005:12"
],
"modified": "2014-10-03",
"publisher": {
"@type": "org:Organization",
"name": "Department of Agriculture"
},
"spatial": null,
"keyword": [
"Congressional Logs"
]
}
]
}
3 changes: 3 additions & 0 deletions ckanext/datajson/tests/mock_datajson_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def do_GET(self):
elif self.path == '/null-spatial':
self.sample_datajson_file = 'null-spatial.data.json'
self.test_name = 'null-spatial'
elif self.path == '/numerical-title':
self.sample_datajson_file = 'numerical-title.data.json'
self.test_name = 'numerical-title'
elif self.path == '/text':
self.test_name = 'test'
self.respond('abc123', status=200)
Expand Down
7 changes: 7 additions & 0 deletions ckanext/datajson/tests/test_datajson_ckan_all_harvester.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,3 +637,10 @@ def test_datajson_null_spatial(self):
dataset = datasets[0]
expected_title = "Sample Title NUll Spatial"
assert dataset.title == expected_title

def test_datajson_numerical_title(self):
url = 'http://127.0.0.1:%s/numerical-title' % self.mock_port
datasets = self.run_source(url=url)
dataset = datasets[0]
expected_title = "707"
assert dataset.title == expected_title
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='ckanext-datajson',
version='0.1.11',
version='0.1.12',
description="CKAN extension to generate /data.json",
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 010aa45

Please sign in to comment.