From 7f0bf9712447ea5954c1188071719b999611ea2a Mon Sep 17 00:00:00 2001 From: avdata99 Date: Fri, 4 Oct 2024 09:42:52 -0300 Subject: [PATCH] New test --- ...thon-publish.yml => python-publish.yml.no} | 0 tests/static/simple-semicolon.csv | 7 +++++ tests/test_acceptance.py | 27 +++++++++++++++++++ 3 files changed, 34 insertions(+) rename .github/workflows/{python-publish.yml => python-publish.yml.no} (100%) create mode 100644 tests/static/simple-semicolon.csv diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml.no similarity index 100% rename from .github/workflows/python-publish.yml rename to .github/workflows/python-publish.yml.no diff --git a/tests/static/simple-semicolon.csv b/tests/static/simple-semicolon.csv new file mode 100644 index 0000000..6ea8a3b --- /dev/null +++ b/tests/static/simple-semicolon.csv @@ -0,0 +1,7 @@ +date;temperature;place +2011-01-01;1;Galway +2011-01-02;-1;Galway +2011-01-03;0;Galway +2011-01-01;6;Berkeley,something else +2011-01-02;8;Berkeley +2011-01-03;5;Berkeley \ No newline at end of file diff --git a/tests/test_acceptance.py b/tests/test_acceptance.py index 117d0ee..4eefafc 100644 --- a/tests/test_acceptance.py +++ b/tests/test_acceptance.py @@ -311,6 +311,33 @@ def test_simple_ssv(self): {'date': datetime.datetime(2011, 1, 1, 0, 0), 'place': 'Galway', 'temperature': 1}) + @httpretty.activate + def test_simple_ssv_with_csv_ext(self): + """Same as test_simple_ssv but for a semicolon separated file with CSV extension + """ + self.register_urls('simple-semicolon.csv', 'csv', 'application/csv') + data = { + 'api_key': self.api_key, + 'job_type': 'push_to_datastore', + 'metadata': { + 'ckan_url': 'http://%s/' % self.host, + 'resource_id': self.resource_id + } + } + + headers, results = jobs.push_to_datastore('fake_id', data, True) + results = list(results) + expected_headers = [ + {'type': 'timestamp', 'id': 'date'}, + {'type': 'numeric', 'id': 'temperature'}, + {'type': 'text', 'id': 'place'} + ] + assert (headers == expected_headers) + assert len(results) == 6 + assert (results[0] == + {'date': datetime.datetime(2011, 1, 1, 0, 0), + 'place': 'Galway', 'temperature': 1}) + @httpretty.activate def test_simple_xls(self): """Test successfully fetching and parsing a simple XLS file.