Skip to content

Commit

Permalink
Update file paths
Browse files Browse the repository at this point in the history
Signed-off-by: Kipchirchir Sigei <[email protected]>
  • Loading branch information
KipSigei committed Apr 22, 2022
1 parent eb75502 commit 4b5cc2e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion onadata/apps/api/tests/viewsets/test_open_data_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def test_tableau_get_nested_repeat_group_data(self):
# Create form with nested repeat groups
xls_file_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"../../../main/tests/fixtures/transportation/transportation.xlsx"
"../../../main/tests/fixtures/transportation/transportation_1.xlsx"
)
self._publish_xls_file_and_set_xform(xls_file_path)

Expand Down
Binary file not shown.
23 changes: 12 additions & 11 deletions onadata/apps/main/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

import pytz
import requests
import openpyxl
from django.conf import settings
from django.core.files.uploadedfile import UploadedFile
from django.urls import reverse
from django_digest.test import Client as DigestClient
from future.utils import iteritems
from mock import patch
from openpyxl import load_workbook

from onadata.apps.logger.models import XForm
from onadata.apps.logger.models.xform import XFORM_TITLE_LENGTH
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_publish_xlsx_file(self):
def test_google_url_upload(self, mock_urlopen, mock_requests):
if self._internet_on(url="http://google.com"):
xls_url = "https://docs.google.com/spreadsheet/pub?"\
"key=0AvhZpT7ZLAWmdDhISGhqSjBOSl9XdXd5SHZHUUE2RFE&output=xls"
"key=0AvhZpT7ZLAWmdDhISGhqSjBOSl9XdXd5SHZHUUE2RFE&output=xlsx"
pre_count = XForm.objects.count()

path = os.path.join(
Expand All @@ -109,7 +109,7 @@ def test_google_url_upload(self, mock_urlopen, mock_requests):
"officedocument.spreadsheetml.sheet"),
'content-disposition': (
'attachment; filename="transportation.'
'xls"; filename*=UTF-8\'\'transportation.xlsx')
'xlsx"; filename*=UTF-8\'\'transportation.xlsx')
}
mock_requests.get.return_value = mock_response
mock_urlopen.return_value = xls_file
Expand Down Expand Up @@ -215,7 +215,7 @@ def _publish_file(self, xls_path, strict=True):

def _publish_xls_file(self):
xls_path = os.path.join(self.this_directory, "fixtures",
"transportation", "transportation_1.xlsx")
"transportation", "transportation.xlsx")
self._publish_file(xls_path)
self.assertEqual(self.xform.id_string, "transportation_2011_07_25")

Expand Down Expand Up @@ -465,11 +465,11 @@ def _check_xls_export(self):
'xls_export', kwargs={'username': self.user.username,
'id_string': self.xform.id_string})
response = self.client.get(xls_export_url)
expected_xls = load_workbook(os.path.join(
expected_xls = openpyxl.open(filename=os.path.join(
self.this_directory, "fixtures", "transportation",
"transportation_export.xlsx"))
"transportation_export.xlsx"), data_only=True)
content = get_response_content(response, decode=False)
actual_xls = load_workbook(filename=BytesIO(content))
actual_xls = openpyxl.load_workbook(filename=BytesIO(content))
actual_sheet = actual_xls.get_sheet_by_name('data')
expected_sheet = expected_xls.get_sheet_by_name('transportation')
# check headers
Expand All @@ -482,12 +482,13 @@ def _check_xls_export(self):
self.assertEqual(len(list(actual_sheet.rows)),
len(list(expected_sheet.rows)))
for i in range(1, len(list(actual_sheet.columns))):
actual_row = list(actual_sheet.values)[i]
expected_row = list(expected_sheet.values)[i]
i = 1
actual_row = list(list(actual_sheet.values)[i])
expected_row = list(list(expected_sheet.values)[i])

# remove _id from result set, varies depending on the database
del list(actual_row)[23]
del list(expected_row)[23]
del actual_row[23]
del expected_row[23]
self.assertEqual(actual_row, expected_row)

def _check_delete(self):
Expand Down

0 comments on commit 4b5cc2e

Please sign in to comment.