From 2851718e1a109d5e42f0171f3ddcb00e32c0033a Mon Sep 17 00:00:00 2001 From: Kelvin Muchiri Date: Tue, 14 Jan 2025 17:17:41 +0300 Subject: [PATCH] address lint warning --- .../logger/management/commands/export_data.py | 16 ++++++++++------ .../management/commands/test_export_data.py | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/onadata/apps/logger/management/commands/export_data.py b/onadata/apps/logger/management/commands/export_data.py index c04bd956d0..10b5ecb441 100644 --- a/onadata/apps/logger/management/commands/export_data.py +++ b/onadata/apps/logger/management/commands/export_data.py @@ -1,12 +1,16 @@ # -*- coding: utf-8 -*- +""" +Management command to export data from a form in CSV format. +""" + from django.core.management.base import BaseCommand +from codetiming import Timer + from onadata.apps.logger.models.xform import XForm from onadata.apps.viewer.models.export import Export from onadata.libs.utils.export_tools import generate_export -from codetiming import Timer - class Command(BaseCommand): help = "Exports data from a form in CSV format" @@ -35,8 +39,8 @@ def handle(self, *args: str, **options: str): plural_or_singular = ( "submission" if xform.num_of_submissions == 1 else "submissions" ) - self.stdout.write( - self.style.SUCCESS( - f'{export.pk}: Exporting {xform.num_of_submissions} {plural_or_singular} of the form "{xform.title}"' - ) + msg = ( + f"{export.pk}: Exporting {xform.num_of_submissions}" + f'{plural_or_singular} of the form "{xform.title}"' ) + self.stdout.write(self.style.SUCCESS(msg)) diff --git a/onadata/apps/logger/tests/management/commands/test_export_data.py b/onadata/apps/logger/tests/management/commands/test_export_data.py index 0791f37b97..a2029bfab0 100644 --- a/onadata/apps/logger/tests/management/commands/test_export_data.py +++ b/onadata/apps/logger/tests/management/commands/test_export_data.py @@ -1,15 +1,22 @@ # -*- coding: utf-8 -*- +""" +Tests for the onadata.apps.logger.management.commands.export_data module. +""" from io import StringIO from django.core.management import call_command from django.core.management.base import CommandError + from onadata.apps.main.tests.test_base import TestBase from onadata.apps.viewer.models.export import Export class ExportDataTest(TestBase): + """Tests for the export_data management command.""" + def test_command_output(self): + """Test the output of the export_data management command.""" output = StringIO() error_output = StringIO() with self.assertRaisesMessage(