-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CONCD-730 Unit tests for management commands (#2392)
* 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
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |