From ada2e8eb739d070dae31d894576c901a795f8701 Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 23 Jul 2015 10:22:59 +0100 Subject: [PATCH] [#2553] Fix autodetect for tsv resources When you upload or link to a TSV file and don't specify a resource format, the format that you end up with is text/tab-separated-values. This is not recognized by the DataPusher and the resource is not uploaded to the DataStore. This patch adds this alternative representation to the canonical resource format list. --- ckan/config/resource_formats.json | 2 +- ckan/tests/lib/test_helpers.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ckan/config/resource_formats.json b/ckan/config/resource_formats.json index a83dc8b3e37..0cf6fb92eaa 100644 --- a/ckan/config/resource_formats.json +++ b/ckan/config/resource_formats.json @@ -18,7 +18,7 @@ ["MDB", "Access Database", "application/x-msaccess", []], ["NetCDF", "NetCDF File", "application/netcdf", []], ["ArcGIS Map Service", "ArcGIS Map Service", "ArcGIS Map Service", ["arcgis map service"]], - ["TSV", "Tab Separated Values File", "text/tsv", []], + ["TSV", "Tab Separated Values File", "text/tsv", ["text/tab-separated-values"]], ["WFS", "Web Feature Service", null, []], ["ArcGIS Online Map", "ArcGIS Online Map", "ArcGIS Online Map", ["web map application"]], ["Perl", "Perl Script", "text/x-perl", []], diff --git a/ckan/tests/lib/test_helpers.py b/ckan/tests/lib/test_helpers.py index a1175dddc20..69e3f48b97b 100644 --- a/ckan/tests/lib/test_helpers.py +++ b/ckan/tests/lib/test_helpers.py @@ -109,3 +109,12 @@ def test_includes_existing_license(self): eq_(dict(licenses)['some-old-license'], 'some-old-license') # and it is first on the list eq_(licenses[0][0], 'some-old-license') + + +class TestResourceFormat(object): + + def test_autodetect_tsv(self): + + eq_(h.unified_resource_format('tsv'), 'TSV') + + eq_(h.unified_resource_format('text/tab-separated-values'), 'TSV')