Skip to content

Commit

Permalink
fix(tests): fixed mock test_upload;
Browse files Browse the repository at this point in the history
- Fixed issues with `test_upload` mock action for tests.
  • Loading branch information
JVickery-TBS committed Aug 23, 2023
1 parent ea5dab1 commit 4262d4f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ckanapi/tests/mock/mock_ckan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import csv
from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server
try:
from cStringIO import StringIO
except ImportError:
from io import StringIO


def mock_ckan(environ, start_response):
status = '200 OK'
Expand Down Expand Up @@ -39,7 +44,14 @@ def mock_ckan(environ, start_response):
environ=environ,
keep_blank_values=True,
)
records = list(csv.reader(fs['upload'].file))
upload_data = fs.getvalue('upload').decode('utf-8').splitlines()
csv_file = StringIO()
writer = csv.writer(csv_file)
for line_data in upload_data:
row_data = line_data.split(',')
writer.writerow(row_data)
csv_file.seek(0)
records = list(csv.reader(csv_file))
start_response(status, headers)
return [json.dumps({
"help": "none",
Expand Down

0 comments on commit 4262d4f

Please sign in to comment.