Keep crisis tags #154
GitHub Actions / Test Results
failed
Jul 25, 2024 in 0s
1 fail, 136 pass in 42s
137 tests 136 ✅ 42s ⏱️
1 suites 0 💤
1 files 1 ❌
Results for commit 94c50a9.
Annotations
Check warning on line 0 in tests.hdx.api.test_ckan.TestCKAN
github-actions / Test Results
test_create_dataset (tests.hdx.api.test_ckan.TestCKAN) failed
test-results.xml [took 2s]
Raw output
hdx.data.hdxobject.HDXError: Country: AFG with iso3: AFG could not be found in HDX list!
self = <test_ckan.TestCKAN object at 0x7fb03112cd10>
datasetmetadata = 'tests/fixtures/CKAN/hdx_dataset_static.yaml'
testdata = 'tests/fixtures/test_data.csv'
setup_teardown_folder = (<gspread.client.Client object at 0x7fb03050e330>, '1D-PS4UfLZQepJAfvxpS45cOCt8sAJMKY')
params = {'corpora': 'teamDrive', 'includeItemsFromAllDrives': True, 'supportsAllDrives': True, 'teamDriveId': '0AKCBfHI3H-hcUk9PVA'}
def test_create_dataset(
self,
datasetmetadata,
testdata,
setup_teardown_folder,
params,
):
today = now_utc()
gclient, folderid = setup_teardown_folder
def create_gsheet(name, update):
payload = {
"name": name,
"mimeType": "application/vnd.google-apps.spreadsheet",
"parents": [folderid],
}
r = gclient.http_client.request(
"post", DRIVE_FILES_API_V3_URL, json=payload, params=params
)
spreadsheetid = r.json()["id"]
gsheet = gclient.open_by_key(spreadsheetid)
wks = gsheet.sheet1
wks.update(update, "A1")
gsheet.share("", role="reader", perm_type="anyone")
return wks, f"{gsheet.url}/export?format=xlsx"
name = "hdx_python_api_test"
dataset = Dataset.read_from_hdx(name)
if dataset:
dataset.delete_from_hdx()
title = "HDX Python API test"
dataset = Dataset({"name": name, "title": title})
dataset.update_from_yaml(datasetmetadata)
maintainer_id = "196196be-6037-4488-8b71-d786adf4c081"
dataset.set_maintainer(maintainer_id)
dataset.set_organization("5a63012e-6c41-420c-8c33-e84b277fdc90")
dataset.set_time_period(today)
dataset.set_expected_update_frequency("Every week")
dataset.set_subnational(True)
countryiso3s = ["AFG", "PSE", "SYR", "YEM"]
> dataset.add_country_locations(countryiso3s)
tests/hdx/api/test_ckan.py:135:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/hdx/data/dataset.py:1732: in add_country_locations
if not self.add_country_location(
src/hdx/data/dataset.py:1705: in add_country_location
return self.add_other_location(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = {'name': 'hdx_python_api_test', 'title': 'HDX Python API test', 'license_id': 'cc-by-sa', 'notes': 'Some notes.', 'cav...c90', 'dataset_date': '[2024-07-25T00:00:00 TO 2024-07-25T00:00:00]', 'data_update_frequency': '7', 'subnational': '1'}
location = 'AFG', exact = True
alterror = 'Country: AFG with iso3: AFG could not be found in HDX list!'
locations = None
def add_other_location(
self,
location: str,
exact: bool = True,
alterror: Optional[str] = None,
locations: Optional[ListTuple[str]] = None,
) -> bool:
"""Add a location which is not a country or region. Value is parsed and compared to existing locations in
HDX. If the location is already added, it is ignored.
Args:
location (str): Location to add
exact (bool): True for exact matching or False to allow fuzzy matching. Defaults to True.
alterror (Optional[str]): Alternative error message to builtin if location not found. Defaults to None.
locations (Optional[ListTuple[str]]): Valid locations list. Defaults to list downloaded from HDX.
Returns:
bool: True if location added or False if location already present
"""
hdx_code, match = Locations.get_HDX_code_from_location_partial(
location, locations=locations, configuration=self.configuration
)
if hdx_code is None or (exact is True and match is False):
if alterror is None:
raise HDXError(f"Location: {location} - cannot find in HDX!")
else:
> raise HDXError(alterror)
E hdx.data.hdxobject.HDXError: Country: AFG with iso3: AFG could not be found in HDX list!
src/hdx/data/dataset.py:1788: HDXError
Loading