diff --git a/openedx/features/survey_report/application.py b/openedx/features/survey_report/application.py new file mode 100644 index 000000000000..9ebba689351e --- /dev/null +++ b/openedx/features/survey_report/application.py @@ -0,0 +1,6 @@ +""" +Contains the logic for manage a survey report. +""" + +def generate_report() -> None: + """ Generate a report with relevant data.""" diff --git a/openedx/features/survey_report/management/__init__.py b/openedx/features/survey_report/management/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/openedx/features/survey_report/management/commands/__init__.py b/openedx/features/survey_report/management/commands/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/openedx/features/survey_report/management/commands/generate_report.py b/openedx/features/survey_report/management/commands/generate_report.py new file mode 100644 index 000000000000..29e9bb89bb93 --- /dev/null +++ b/openedx/features/survey_report/management/commands/generate_report.py @@ -0,0 +1,26 @@ +""" +CLI command to generate survey report. +""" + +from django.core.management.base import BaseCommand, CommandError +from openedx.features.survey_report.application import generate_report + +class Command(BaseCommand): + """ + Management command to generate a new survey report with + non-sensitive data. + """ + + help = """ + This command will create a new survey report using some + models to get the total number oof courses offered, currently active learners, + learners ever registered, and generated certificates. + """ + + def handle(self, *args, **options): + try: + generate_report() + except Exception as error: + raise CommandError('An error has ocurred while report was generating.') from error + + self.stdout.write(self.style.SUCCESS('Survey report has been generated successfully.')) diff --git a/openedx/features/survey_report/management/commands/tests/__init__.py b/openedx/features/survey_report/management/commands/tests/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/openedx/features/survey_report/management/commands/tests/test_generate_report.py b/openedx/features/survey_report/management/commands/tests/test_generate_report.py new file mode 100644 index 000000000000..ab2982301e59 --- /dev/null +++ b/openedx/features/survey_report/management/commands/tests/test_generate_report.py @@ -0,0 +1,13 @@ +""" +Test for generate_report command. +""" + +from io import StringIO +from django.core.management import call_command +from django.test import TestCase + +class GenerateReportTest(TestCase): + def test_command_output(self): + out = StringIO() + call_command('generate_report', stdout=out) + self.assertIn('Survey report has been generated successfully.', out.getvalue())