Skip to content

Commit

Permalink
Ready to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans committed Jul 15, 2024
1 parent 0be5949 commit d13075d
Show file tree
Hide file tree
Showing 3 changed files with 729 additions and 1,916 deletions.
122 changes: 53 additions & 69 deletions tests/hdx/data/test_dataset_noncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,15 @@ def test_get_add_tags(self, configuration, vocabulary_read):
expected = copy.deepcopy(resulttags)
expected.append(
{
"name": "violence and conflict",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"name": "conflict-violence",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
}
)
assert dataset["tags"] == expected
assert dataset.get_tags() == [
"conflict",
"political violence",
"violence and conflict",
"conflict-violence",
]
dataset.add_tags(
[
Expand All @@ -464,71 +464,66 @@ def test_get_add_tags(self, configuration, vocabulary_read):
assert dataset.get_tags() == [
"conflict",
"political violence",
"violence and conflict",
"unemployment",
"fatalities - deaths",
"conflict-violence",
"employment",
"fatalities",
]
dataset.remove_tag("violence and conflict")
dataset.remove_tag("conflict-violence")
assert dataset.get_tags() == [
"conflict",
"political violence",
"unemployment",
"fatalities - deaths",
"employment",
"fatalities",
]
del dataset["tags"]
assert dataset.get_tags() == []
dataset.add_tag("conflict-related deaths")
assert dataset["tags"] == [
{
"name": "violence and conflict",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"name": "conflict-violence",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
},
{
"name": "fatalities - deaths",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"name": "fatalities",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
},
]
assert dataset.get_tags() == [
"violence and conflict",
"fatalities - deaths",
"conflict-violence",
"fatalities",
]
dataset.add_tag("conflict-related deaths")
assert dataset.get_tags() == [
"violence and conflict",
"fatalities - deaths",
"conflict-violence",
"fatalities",
]
dataset.add_tag("cholera")
assert dataset.get_tags() == [
"violence and conflict",
"fatalities - deaths",
"cholera",
"conflict-violence",
"fatalities",
"disease",
]
dataset.remove_tag("violence and conflict")
dataset.remove_tag("conflict-violence")
assert dataset.get_tags() == [
"fatalities - deaths",
"cholera",
"fatalities",
"disease",
]
dataset.add_tag("cholera")
assert dataset.get_tags() == [
"fatalities - deaths",
"cholera",
"fatalities",
"disease",
]
dataset.add_tag("cbi")
assert dataset.get_tags() == [
"fatalities - deaths",
"cholera",
"fatalities",
"disease",
"cash assistance",
"cash based interventions-cbi",
]
dataset.add_tag("lala")
assert dataset.get_tags() == [
"fatalities - deaths",
"cholera",
"fatalities",
"disease",
"cash assistance",
"cash based interventions-cbi",
]

def test_add_clean_tags(self, configuration, vocabulary_read):
Expand All @@ -538,123 +533,112 @@ def test_add_clean_tags(self, configuration, vocabulary_read):
dataset = Dataset(datasetdata)
assert dataset.get_tags() == ["conflict", "political violence"]
assert dataset.clean_tags() == (
["violence and conflict"],
["conflict-violence"],
["political violence"],
)
dataset.add_tags(["nodeid123", "transportation"])
assert dataset.get_tags() == [
"violence and conflict",
"conflict-violence",
"transportation",
]
dataset["tags"].append(
{
"name": "nodeid123",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
}
)
assert dataset.clean_tags() == (
["violence and conflict", "transportation"],
["conflict-violence", "transportation"],
["nodeid123"],
)
assert dataset.get_tags() == [
"violence and conflict",
"conflict-violence",
"transportation",
]
dataset.add_tags(["geodata", "points"])
assert dataset.clean_tags() == (
["violence and conflict", "transportation", "geodata"],
["conflict-violence", "transportation", "geodata"],
[],
)
dataset.add_tag("financial")
assert dataset.get_tags() == [
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
]
dataset["tags"].append(
{
"name": "financial",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
}
)
assert dataset.clean_tags() == (
["violence and conflict", "transportation", "geodata"],
["conflict-violence", "transportation", "geodata"],
["financial"],
)
dataset.add_tag("addresses")
assert dataset.clean_tags() == (
[
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
"3-word addresses",
],
[],
)
dataset.remove_tag("3-word addresses")
dataset.remove_tag("geodata")
assert dataset.get_tags() == [
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
]
dataset.add_tag("cultivos coca")
assert dataset.clean_tags() == (
[
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
"food production",
"livelihoods",
],
[],
)
dataset.remove_tag("food production")
dataset.remove_tag("livelihoods")
dataset.add_tag("atentados")
assert dataset.get_tags() == [
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
"security incidents",
]
dataset["tags"].append(
{
"name": "atentados",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
}
)
assert dataset.clean_tags() == (
[
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
"security incidents",
],
[],
)
dataset.remove_tag("security incidents")
dataset.add_tag("windspeeds")
assert dataset.clean_tags() == (
[
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
"wind speed",
"cyclones-hurricanes-typhoons",
],
[],
)
dataset.add_tag("conservancies")
assert dataset.get_tags() == [
"violence and conflict",
"conflict-violence",
"transportation",
"geodata",
"wind speed",
"protected areas",
"cyclones-hurricanes-typhoons",
"affected area",
]
dataset.remove_tag("transportation")
dataset.remove_tag("protected areas")
dataset.remove_tag("affected area")
assert dataset.get_tags() == [
"violence and conflict",
"geodata",
"wind speed",
"conflict-violence",
"cyclones-hurricanes-typhoons",
]

def test_maintainer(self, configuration, user_read):
Expand Down Expand Up @@ -1784,7 +1768,7 @@ def test_load_save_to_json(self, vocabulary_read):
expected_update_frequency = "Every day"
dataset.set_expected_update_frequency(expected_update_frequency)
dataset.set_subnational(False)
tags = ["hxl", "aid funding"]
tags = ["hxl", "funding"]
dataset.add_tags(tags)
resource_name = "filename.csv"
resourcedata = {
Expand Down
14 changes: 7 additions & 7 deletions tests/hdx/data/test_showcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"resources": [],
"tags": [
{
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
"state": "active",
"display_name": "economics",
"id": "e1ff4b78-efcf-40e7-888b-7342169068e1",
"name": "economics",
},
{
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
"state": "active",
"display_name": "health",
"id": "8a43b269-78cb-4a85-a4ce-7e3e928bc487",
Expand Down Expand Up @@ -400,11 +400,11 @@ def test_update_in_hdx(self, configuration, post_update):
expected["tags"] = [
{
"name": "economics",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
},
{
"name": "health",
"vocabulary_id": "4381925f-0ae9-44a3-b30d-cae35598757b",
"vocabulary_id": "b891512e-9516-4bf5-962a-7a289772a2a1",
},
]
assert showcase.get_old_data_dict() == expected
Expand Down Expand Up @@ -461,15 +461,15 @@ def test_tags(self, configuration):
assert showcase.get_tags() == [
"economy",
"health",
"water sanitation and hygiene - wash",
"water sanitation and hygiene-wash",
]
showcase.add_tags(["sanitation"])
assert showcase.get_tags() == [
"economy",
"health",
"water sanitation and hygiene - wash",
"water sanitation and hygiene-wash",
]
result = showcase.remove_tag("water sanitation and hygiene - wash")
result = showcase.remove_tag("water sanitation and hygiene-wash")
assert result is True
assert showcase.get_tags() == ["economy", "health"]
showcase["tags"] = None
Expand Down
Loading

0 comments on commit d13075d

Please sign in to comment.