Skip to content

Commit

Permalink
enhance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Jan 7, 2025
1 parent 755a7f0 commit fefffc4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions onadata/libs/tests/utils/test_csv_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
from builtins import chr, open
from tempfile import NamedTemporaryFile
from unittest.mock import patch

from django.contrib.contenttypes.models import ContentType
from django.test.utils import override_settings
Expand Down Expand Up @@ -111,7 +112,8 @@ def _csv_data_for_dataframe(self):
)
return [d for d in csv_df_builder._format_for_dataframe(cursor)]

def test_csv_dataframe_export_to(self):
@patch("onadata.libs.utils.csv_builder.register_xform_export_repeats_async.delay")
def test_csv_dataframe_export_to(self, mock_register_repeats):
"""
Test CSVDataFrameBuilder.export_to().
"""
Expand Down Expand Up @@ -143,6 +145,8 @@ def test_csv_dataframe_export_to(self):
with open(temp_file.name) as csv_file:
self._test_csv_files(csv_file, csv_fixture_path)
os.unlink(temp_file.name)
# Repeat register is created for future use
mock_register_repeats.assert_called_once_with(self.xform.id)

# pylint: disable=invalid-name
def test_csv_columns_for_gps_within_groups(self):
Expand Down Expand Up @@ -2284,7 +2288,8 @@ def test_registered_repeats(self):
self.assertEqual(row, expected_row)
csv_file.close()

def test_registered_repeat_not_found(self):
@patch("onadata.libs.utils.csv_builder.register_xform_export_repeats_async.delay")
def test_registered_repeat_not_found(self, mock_register_repeats):
"""Registered repeat not found in MetaData
If a registered repeat is not found in MetaData, the columns
Expand Down Expand Up @@ -2401,3 +2406,4 @@ def test_registered_repeat_not_found(self):
header = next(csv_reader)
self.assertCountEqual(header, expected_header)
csv_file.close()
mock_register_repeats.assert_called()

0 comments on commit fefffc4

Please sign in to comment.