Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvin-muchiri committed Oct 23, 2024
1 parent ba92dd4 commit 6e475b9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
16 changes: 15 additions & 1 deletion onadata/libs/tests/utils/test_csv_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2115,8 +2115,22 @@ def test_extra_columns_dataview(self):
include_images=False,
show_choice_labels=True,
)
extra_cols = [
"_id",
"_uuid",
"_submission_time",
"_date_modified",
"_tags",
"_notes",
"_version",
"_duration",
"_submitted_by",
"_total_media",
"_media_count",
"_media_all_received",
]

for extra_col in csv_df_builder.extra_columns:
for extra_col in extra_cols:
dataview = DataView.objects.create(
xform=xform,
name="test",
Expand Down
35 changes: 25 additions & 10 deletions onadata/libs/tests/utils/test_export_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3679,13 +3679,28 @@ def test_extra_columns_dataview(self):
)
export_builder = ExportBuilder()
export_builder.set_survey(self.xform.survey)
dataview = DataView.objects.create(
xform=self.xform,
name="test",
columns=["name", "_id"],
project=self.project,
)
fields = export_builder.get_fields(
dataview, export_builder.sections[0], "title"
)
self.assertEqual(fields, ["name", "_id"])
extra_cols = [
"_id",
"_uuid",
"_submission_time",
"_index",
"_parent_table_name",
"_parent_index",
"_tags",
"_notes",
"_version",
"_duration",
"_submitted_by",
]

for extra_col in extra_cols:
dataview = DataView.objects.create(
xform=self.xform,
name="test",
columns=["name", extra_col],
project=self.project,
)
fields = export_builder.get_fields(
dataview, export_builder.sections[0], "title"
)
self.assertEqual(fields, ["name", extra_col])

0 comments on commit 6e475b9

Please sign in to comment.