Update to latest Hatch #146
3 fail, 134 pass in 40s
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 5s]
Raw output
hdx.data.hdxobject.HDXError: Country: AFG with iso3: AFG could not be found in HDX list!
self = <test_ckan.TestCKAN object at 0x7f6adcffb5c0>
datasetmetadata = 'tests/fixtures/CKAN/hdx_dataset_static.yaml'
testdata = 'tests/fixtures/test_data.csv'
setup_teardown_folder = (<gspread.client.Client object at 0x7f6ad72cb800>, '1Z0kvIJYNaIGSZ208xiUYo4jdNnasjvFE')
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:1728: in add_country_locations
if not self.add_country_location(
src/hdx/data/dataset.py:1701: 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-15T00:00:00 TO 2024-07-15T00: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:1784: HDXError
Check warning on line 0 in tests.hdx.data.test_showcase.TestShowcase
github-actions / Test Results
test_update_in_hdx (tests.hdx.data.test_showcase.TestShowcase) failed
test-results.xml [took 0s]
Raw output
hdx.data.hdxobject.HDXError: Field tags is empty in showcase!
self = <data.test_showcase.TestShowcase object at 0x7f6adc552d20>
configuration = None, post_update = None
def test_update_in_hdx(self, configuration, post_update):
showcase = Showcase()
showcase["id"] = "NOTEXIST"
with pytest.raises(HDXError):
showcase.update_in_hdx()
showcase["title"] = "LALA"
with pytest.raises(HDXError):
showcase.update_in_hdx()
showcase = Showcase.read_from_hdx(
"05e392bf-04e0-4ca6-848c-4e87bba10746"
)
assert showcase["id"] == "05e392bf-04e0-4ca6-848c-4e87bba10746"
assert showcase["title"] == "MyShowcase1"
showcase["name"] = "TEST1"
showcase["notes"] = "lalalala"
> showcase.update_in_hdx()
tests/hdx/data/test_showcase.py:393:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/hdx/data/showcase.py:125: in update_in_hdx
self._hdx_update("showcase", "name", force_active=True, **kwargs)
src/hdx/data/hdxobject.py:300: in _hdx_update
self._check_kwargs_fields(object_type, **kwargs)
src/hdx/data/hdxobject.py:276: in _check_kwargs_fields
self.check_required_fields(ignore_fields=ignore_fields)
src/hdx/data/showcase.py:111: in check_required_fields
self._check_required_fields("showcase", ignore_fields)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = {'relationships_as_object': [], 'num_tags': 2, 'id': '05e392bf-04e0-4ca6-848c-4e87bba10746', 'metadata_created': '2017...http://visualisation/url/', 'title': 'MyShowcase1', 'image_display_url': 'http://myvisual/visual.png', 'name': 'TEST1'}
object_type = 'showcase', ignore_fields = []
def _check_required_fields(
self, object_type: str, ignore_fields: ListTuple[str]
) -> None:
"""Helper method to check that metadata for HDX object is complete
Args:
ignore_fields (ListTuple[str]): Any fields to ignore in the check
Returns:
None
"""
for field in self.configuration[object_type]["required_fields"]:
if field not in ignore_fields:
if field not in self.data:
raise HDXError(
f"Field {field} is missing in {object_type}!"
)
if not self.data[field] and not isinstance(
self.data[field], bool
):
> raise HDXError(f"Field {field} is empty in {object_type}!")
E hdx.data.hdxobject.HDXError: Field tags is empty in showcase!
src/hdx/data/hdxobject.py:242: HDXError
Check warning on line 0 in tests.hdx.data.test_showcase.TestShowcase
github-actions / Test Results
test_tags (tests.hdx.data.test_showcase.TestShowcase) failed
test-results.xml [took 0s]
Raw output
AssertionError: assert ['economy', 'health'] == ['economy', '...giene - wash']
Right contains one more item: #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mwater sanitation and hygiene - wash#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
Full diff:
#x1B[0m#x1B[90m #x1B[39;49;00m [#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m 'economy',#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m 'health',#x1B[90m#x1B[39;49;00m
#x1B[91m- 'water sanitation and hygiene - wash',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m ]#x1B[90m#x1B[39;49;00m
self = <data.test_showcase.TestShowcase object at 0x7f6adc99b380>
configuration = None
def test_tags(self, configuration):
showcase_data = copy.deepcopy(TestShowcase.showcase_data)
showcase = Showcase(showcase_data)
assert showcase.get_tags() == ["economy", "health"]
showcase.add_tag("wash")
> assert showcase.get_tags() == [
"economy",
"health",
"water sanitation and hygiene - wash",
]
E AssertionError: assert ['economy', 'health'] == ['economy', '...giene - wash']
E
E Right contains one more item: #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mwater sanitation and hygiene - wash#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E
E Full diff:
E #x1B[0m#x1B[90m #x1B[39;49;00m [#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m 'economy',#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m 'health',#x1B[90m#x1B[39;49;00m
E #x1B[91m- 'water sanitation and hygiene - wash',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m ]#x1B[90m#x1B[39;49;00m
tests/hdx/data/test_showcase.py:461: AssertionError
Check notice on line 0 in .github
github-actions / Test Results
137 tests found
There are 137 tests, see "Raw output" for the full list of tests.
Raw output
tests.hdx.api.test_ckan.TestCKAN ‑ test_create_dataset
tests.hdx.api.test_configuration.TestConfiguration ‑ test_create_set_configuration
tests.hdx.api.test_configuration.TestConfiguration ‑ test_env_vars
tests.hdx.api.test_configuration.TestConfiguration ‑ test_get_hdx_key_site
tests.hdx.api.test_configuration.TestConfiguration ‑ test_hdx_configuration_dict
tests.hdx.api.test_configuration.TestConfiguration ‑ test_hdx_configuration_json
tests.hdx.api.test_configuration.TestConfiguration ‑ test_hdx_configuration_yaml
tests.hdx.api.test_configuration.TestConfiguration ‑ test_init
tests.hdx.api.test_configuration.TestConfiguration ‑ test_project_configuration_dict
tests.hdx.api.test_configuration.TestConfiguration ‑ test_project_configuration_json
tests.hdx.api.test_configuration.TestConfiguration ‑ test_project_configuration_yaml
tests.hdx.api.test_configuration.TestConfiguration ‑ test_remoteckan_validlocations
tests.hdx.api.test_configuration.TestConfiguration ‑ test_set_hdx_key_value
tests.hdx.api.test_configuration.TestConfiguration ‑ test_user_agent
tests.hdx.api.test_locations.TestHDXLocations ‑ test_validlocations
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_add_update_delete_resources
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_autocomplete
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_create_in_hdx
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_delete_from_hdx
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_get_all_dataset_names
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_get_all_datasets
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_get_all_resources
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_hdxconnect
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_read_from_hdx
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_reorder_resources
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_revise
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_search_in_hdx
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_update_in_hdx
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_update_json
tests.hdx.data.test_dataset_core.TestDatasetCore ‑ test_update_yaml
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_add_clean_tags
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_add_update_delete_showcase
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_download_and_generate_resource
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_generate_qc_resource_from_rows
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_generate_resource_view
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_get_add_location
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_get_add_tags
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_get_api_url
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_get_hdx_url
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_get_name_or_id
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_get_set_date_of_dataset
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_get_set_expected_update_frequency
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_is_set_subnational
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_load_save_to_json
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_maintainer
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_organization
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_quickcharts_resource_last
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_remove_dates_from_title
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_set_dataset_year_range
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_set_quickchart_resource
tests.hdx.data.test_dataset_noncore.TestDatasetNoncore ‑ test_transform_update_frequency
tests.hdx.data.test_dataset_title_helper.TestDatasetTitleHelper ‑ test_fuzzy_match_dates_in_title
tests.hdx.data.test_dataset_title_helper.TestDatasetTitleHelper ‑ test_get_date_from_title
tests.hdx.data.test_filestore_helper.TestFilestoreHelper ‑ test_dataset_update_filestore_resource
tests.hdx.data.test_organization.TestOrganization ‑ test_autocomplete
tests.hdx.data.test_organization.TestOrganization ‑ test_create_in_hdx
tests.hdx.data.test_organization.TestOrganization ‑ test_delete_from_hdx
tests.hdx.data.test_organization.TestOrganization ‑ test_get_all_organizations
tests.hdx.data.test_organization.TestOrganization ‑ test_get_datasets
tests.hdx.data.test_organization.TestOrganization ‑ test_read_from_hdx
tests.hdx.data.test_organization.TestOrganization ‑ test_update_in_hdx
tests.hdx.data.test_organization.TestOrganization ‑ test_update_json
tests.hdx.data.test_organization.TestOrganization ‑ test_update_yaml
tests.hdx.data.test_organization.TestOrganization ‑ test_users
tests.hdx.data.test_resource.TestResource ‑ test_check_required_fields
tests.hdx.data.test_resource.TestResource ‑ test_check_url_filetoupload
tests.hdx.data.test_resource.TestResource ‑ test_create_in_hdx
tests.hdx.data.test_resource.TestResource ‑ test_datastore
tests.hdx.data.test_resource.TestResource ‑ test_date_data_updated
tests.hdx.data.test_resource.TestResource ‑ test_delete_from_hdx
tests.hdx.data.test_resource.TestResource ‑ test_download
tests.hdx.data.test_resource.TestResource ‑ test_get_api_url
tests.hdx.data.test_resource.TestResource ‑ test_get_dataset
tests.hdx.data.test_resource.TestResource ‑ test_get_hdx_url
tests.hdx.data.test_resource.TestResource ‑ test_get_set_date_of_resource
tests.hdx.data.test_resource.TestResource ‑ test_mark_broken
tests.hdx.data.test_resource.TestResource ‑ test_patch
tests.hdx.data.test_resource.TestResource ‑ test_read_from_hdx
tests.hdx.data.test_resource.TestResource ‑ test_resource_views
tests.hdx.data.test_resource.TestResource ‑ test_search_in_hdx
tests.hdx.data.test_resource.TestResource ‑ test_update_in_hdx
tests.hdx.data.test_resource.TestResource ‑ test_update_json
tests.hdx.data.test_resource.TestResource ‑ test_update_yaml
tests.hdx.data.test_resource_view.TestResourceView ‑ test_copy
tests.hdx.data.test_resource_view.TestResourceView ‑ test_create_in_hdx
tests.hdx.data.test_resource_view.TestResourceView ‑ test_delete_from_hdx
tests.hdx.data.test_resource_view.TestResourceView ‑ test_get_all_for_resource
tests.hdx.data.test_resource_view.TestResourceView ‑ test_read_from_hdx
tests.hdx.data.test_resource_view.TestResourceView ‑ test_update_in_hdx
tests.hdx.data.test_resource_view.TestResourceView ‑ test_update_json
tests.hdx.data.test_resource_view.TestResourceView ‑ test_update_yaml
tests.hdx.data.test_showcase.TestShowcase ‑ test_create_in_hdx
tests.hdx.data.test_showcase.TestShowcase ‑ test_datasets
tests.hdx.data.test_showcase.TestShowcase ‑ test_delete_from_hdx
tests.hdx.data.test_showcase.TestShowcase ‑ test_get_all_showcases
tests.hdx.data.test_showcase.TestShowcase ‑ test_read_from_hdx
tests.hdx.data.test_showcase.TestShowcase ‑ test_search_in_hdx
tests.hdx.data.test_showcase.TestShowcase ‑ test_tags
tests.hdx.data.test_showcase.TestShowcase ‑ test_update_in_hdx
tests.hdx.data.test_showcase.TestShowcase ‑ test_update_json
tests.hdx.data.test_showcase.TestShowcase ‑ test_update_yaml
tests.hdx.data.test_update_dataset_resources.TestUpdateDatasetResourcesLogic ‑ test_dataset_update_resources
tests.hdx.data.test_update_logic.TestUpdateLogic ‑ test_update_logic_1
tests.hdx.data.test_update_logic.TestUpdateLogic ‑ test_update_logic_2
tests.hdx.data.test_update_logic.TestUpdateLogic ‑ test_update_logic_3
tests.hdx.data.test_user.TestUser ‑ test_autocomplete
tests.hdx.data.test_user.TestUser ‑ test_create_in_hdx
tests.hdx.data.test_user.TestUser ‑ test_delete_from_hdx
tests.hdx.data.test_user.TestUser ‑ test_get_all_users
tests.hdx.data.test_user.TestUser ‑ test_get_organizations
tests.hdx.data.test_user.TestUser ‑ test_get_organizations_invalid_user
tests.hdx.data.test_user.TestUser ‑ test_get_token_list
tests.hdx.data.test_user.TestUser ‑ test_read_from_hdx
tests.hdx.data.test_user.TestUser ‑ test_update_in_hdx
tests.hdx.data.test_user.TestUser ‑ test_update_json
tests.hdx.data.test_user.TestUser ‑ test_update_yaml
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_autocomplete
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_chainrule_error
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_create_approved_vocabulary
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_create_in_hdx
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_delete_approved_vocabulary
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_delete_from_hdx
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_get_all_vocabularies
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_get_approved_vocabulary
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_init
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_read_from_hdx
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_tag_mappings
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_tags
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_update_approved_vocabulary
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_update_in_hdx
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_update_json
tests.hdx.data.test_vocabulary.TestVocabulary ‑ test_update_yaml
tests.hdx.facades.test_infer_arguments.TestInferArguments ‑ test_facade
tests.hdx.facades.test_keyword_arguments.TestKeywordArguments ‑ test_exception
tests.hdx.facades.test_keyword_arguments.TestKeywordArguments ‑ test_facade
tests.hdx.facades.test_simple.TestSimple ‑ test_exception
tests.hdx.facades.test_simple.TestSimple ‑ test_facade