Skip to content

Commit

Permalink
fix: Logic while exporting session CSV and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal committed Oct 1, 2019
1 parent 3d2a1eb commit f09caa6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/api/helpers/csv_jobs_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def export_sessions_csv(sessions):
column.append(session.level)
column.append(session.state)
column.append(session.session_type if session.session_type else '')
column.append(len(session.long_abstract))
column.append(len(session.long_abstract) if session.long_abstract else None)
rows.append(column)

return rows
Expand Down
22 changes: 19 additions & 3 deletions tests/all/integration/api/helpers/test_csv_jobs_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,30 @@ def test_export_attendees_csv(self):
self.assertEqual(field_data[1][3], common.string_)
self.assertEqual(field_data[1][5], '[email protected]')

def _test_export_session_csv(self, test_session=None):
with app.test_request_context():
if not test_session:
test_session = SessionFactory()
field_data = export_sessions_csv([test_session])
session_row = field_data[1]

self.assertEqual(session_row[0], 'example (accepted)')
self.assertEqual(session_row[7], 'accepted')

def test_export_sessions_csv(self):
"""Method to check sessions data export"""

with app.test_request_context():
self._test_export_session_csv()

def test_export_sessions_none_csv(self):
"""Method to check sessions data export with no abstract"""

with app.test_request_context():
test_session = SessionFactory()
field_data = export_sessions_csv([test_session])
self.assertEqual(field_data[1][6], common.int_)
self.assertEqual(field_data[1][7], 'accepted')
test_session.long_abstract = None
test_session.level = None
self._test_export_session_csv(test_session)

def test_export_speakers_csv(self):
"""Method to check speakers data export"""
Expand Down

0 comments on commit f09caa6

Please sign in to comment.