Skip to content

Commit

Permalink
New test
Browse files Browse the repository at this point in the history
  • Loading branch information
avdata99 committed Oct 4, 2024
1 parent 055737b commit 7f0bf97
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
File renamed without changes.
7 changes: 7 additions & 0 deletions tests/static/simple-semicolon.csv
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions tests/test_acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7f0bf97

Please sign in to comment.