Skip to content

Commit

Permalink
CONCD-730 Unit tests for management commands (#2392)
Browse files Browse the repository at this point in the history
* CONCD-730 Unit tests for management commands (WiP)

* CONCD-730 unit test for import_site_reports (WiP)

* CONCD-730 added test csv file

* CONCD-730 test case where row is missing campaign id

* CONCD-730 unit test for ensure_initial_site_configuration management command

---------

Co-authored-by: Jennifer Kuenning <72825410+jkueloc@users.noreply.github.com>
  • Loading branch information
rasarkar and jkueloc authored May 30, 2024
1 parent d85d0d3 commit 85abbfb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions concordia/tests/data/site_reports.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
created_on,time,campaign
05/27/2024,10:13 PM UTC,1
05/26/2024,10:12 PM UTC,
39 changes: 39 additions & 0 deletions concordia/tests/test_management_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from io import StringIO

from django.core.management import call_command
from django.test import TestCase

from concordia.tests.utils import create_asset, create_campaign


class EnsureInitialSiteConfigurationTests(TestCase):
def test_command_output(self, *args, **kwargs):
out = StringIO()
call_command(
"ensure_initial_site_configuration", admin_email="admin@loc.gov", stdout=out
)
call_command(
"ensure_initial_site_configuration", site_domain="crowd.loc.gov", stdout=out
)


class ImportSiteReportsTests(TestCase):
def test_command_output(self, *args, **kwargs):
out = StringIO()
create_campaign(id=1)
call_command(
"import_site_reports",
csv_file="concordia/tests/data/site_reports.csv",
stdout=out,
)


class PrintFrontendTestUrlsTests(TestCase):
def test_command_output(self, *args, **kwargs):
out = StringIO()
call_command("print_frontend_test_urls", stdout=out)
self.assertIn("", out.getvalue())

create_asset()
call_command("print_frontend_test_urls", stdout=out)
self.assertIn("", out.getvalue())

0 comments on commit 85abbfb

Please sign in to comment.