Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #103 from open-contracting/102-fix-to-json
Browse files Browse the repository at this point in the history
Fix to-json for url input
  • Loading branch information
aguilerapy committed Jul 2, 2020
2 parents a5363c0 + d1bc1cd commit 40f1801
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion default/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ def upload_url(request):
if 'input_url' in data:
url = request.POST.get(data)
basename = data
extension = ".json"
if request.POST.get('type') == 'csv xlsx zip':
extension = os.path.splitext(urlparse(url).path)[1]
else:
extension = ".json"
folder = 'media'
data_file = DataFile(basename, extension)

Expand Down
10 changes: 10 additions & 0 deletions tests/test_upload_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def test_upload_url_status(self):
response = self.client.get('/upload-url/status/')
self.assertEqual(response.status_code, 200)

def test_upload_csv_xlsx_zip(self):
file_url = {
'input_url_0': 'https://github.com/open-contracting/toucan/blob/master/tests/fixtures/'
'1.1/spreadsheets/flattened.xlsx?raw=true',
'type': 'csv xlsx zip'
}
self.client.post('/upload-url/', file_url)
response = self.client.get('/upload-url/status/')
self.assertEqual(response.status_code, 200)

def test_bad_url(self):
bad_files_urls = {
'input_url_0': 'https://raw.githubusercontent.com/open-contracting/toucan/'
Expand Down

0 comments on commit 40f1801

Please sign in to comment.