Skip to content

Commit

Permalink
Merge 4085c4d into 7d81793
Browse files Browse the repository at this point in the history
  • Loading branch information
lrromero committed Aug 8, 2018
2 parents 7d81793 + 4085c4d commit b6e5410
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pydatajson/indicators.py
Expand Up @@ -674,4 +674,4 @@ def _filter_by_likely_publisher(central_datasets, catalog_datasets):

def count_fields(targets, field):
"""Cuenta la cantidad de values en el key especificado de una lista de diccionarios"""
return Counter([target[field] for target in targets if field in target])
return Counter([target.get(field) or 'None' for target in targets])
32 changes: 20 additions & 12 deletions tests/test_indicators.py
Expand Up @@ -96,7 +96,8 @@ def test_format_indicators(self):
'distribuciones_formatos_cant': {
'CSV': 1,
'XLSX': 1,
'PDF': 1
'PDF': 1,
'None': 3
}
}

Expand All @@ -113,6 +114,7 @@ def test_license_indicators(self):
'datasets_licencias_cant': {
'Open Data Commons Open Database License 1.0': 1,
'Creative Commons Attribution': 1,
'None': 1
}
}

Expand All @@ -124,7 +126,7 @@ def test_no_licenses_indicators(self):
# No tienen licencias
catalog = os.path.join(self.SAMPLES_DIR, "several_datasets_for_harvest.json")
indicators = self.dj.generate_catalogs_indicators(catalog)[0][0]
assert_equal(indicators['datasets_licencias_cant'], {})
assert_equal(indicators['datasets_licencias_cant'], {'None': 3})

@my_vcr.use_cassette()
def test_field_indicators_on_min_catalog(self):
Expand Down Expand Up @@ -262,14 +264,17 @@ def test_network_indicators(self):
'distribuciones_formatos_cant': {
'CSV': 2,
'XLSX': 1,
'PDF': 2
'PDF': 2,
'None': 3
},
'distribuciones_tipos_cant': {
'file': 1,
'documentation': 1
'documentation': 1,
'None': 6
},
'datasets_licencias_cant': {
'Open Data Commons Open Database License 1.0': 2,
'None': 3
},
'campos_optativos_pct': 32.56,
'campos_recomendados_pct': 50.72,
Expand All @@ -296,6 +301,7 @@ def test_network_license_indicators(self):
'datasets_licencias_cant': {
'Open Data Commons Open Database License 1.0': 3,
'Creative Commons Attribution': 1,
'None': 1
},
}

Expand All @@ -320,10 +326,11 @@ def test_network_type_indicators(self):
'catalogos_cant': 2,
'distribuciones_cant': 8,
'distribuciones_tipos_cant': {
"file": 2,
"file.upload": 1,
"documentation": 2,
"api": 2
'file': 2,
'file.upload': 1,
'documentation': 2,
'api': 2,
'None': 1,
}
}

Expand All @@ -338,10 +345,11 @@ def test_types_indicators(self):

expected = {
'distribuciones_tipos_cant': {
"file": 1,
"file.upload": 1,
"documentation": 1,
"api": 2
'file': 1,
'file.upload': 1,
'documentation': 1,
'api': 2,
'None': 1
}
}

Expand Down

0 comments on commit b6e5410

Please sign in to comment.