mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 19:09:22 +02:00
Final test cases
This commit is contained in:
parent
63dd354da8
commit
4594eb7ca3
3 changed files with 29 additions and 9 deletions
1
.github/workflows/daily-csv-upload.yaml
vendored
1
.github/workflows/daily-csv-upload.yaml
vendored
|
@ -2,7 +2,6 @@ name: Upload current-full.csv and current-federal.csv
|
||||||
run-name: Upload current-full.csv and current-federal.csv for branch ${{ github.head_ref }}
|
run-name: Upload current-full.csv and current-federal.csv for branch ${{ github.head_ref }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
environment:
|
environment:
|
||||||
|
|
4
src/registrar/tests/data/fake_current_full.csv
Normal file
4
src/registrar/tests/data/fake_current_full.csv
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Domain name,Domain type,Agency,Organization name,City,State,Security Contact Email
|
||||||
|
cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,,
|
||||||
|
ddomain3.gov,Federal,Armed Forces Retirement Home,,,,
|
||||||
|
adomain2.gov,Interstate,,,,,
|
|
|
@ -5,7 +5,6 @@ from io import StringIO
|
||||||
from registrar.models.domain_information import DomainInformation
|
from registrar.models.domain_information import DomainInformation
|
||||||
from registrar.models.domain import Domain
|
from registrar.models.domain import Domain
|
||||||
from registrar.models.user import User
|
from registrar.models.user import User
|
||||||
from os import linesep
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from registrar.utility.csv_export import export_domains_to_writer
|
from registrar.utility.csv_export import export_domains_to_writer
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
@ -105,10 +104,10 @@ class CsvReportsTest(TestCase):
|
||||||
def test_generate_full_report(self):
|
def test_generate_full_report(self):
|
||||||
"""Ensures that we correctly generate current-full.csv"""
|
"""Ensures that we correctly generate current-full.csv"""
|
||||||
expected_file_content = [
|
expected_file_content = [
|
||||||
call(f"Domain name,Domain type,Agency,Organization name,City,State,Security Contact Email{linesep}"),
|
call(f"Domain name,Domain type,Agency,Organization name,City,State,Security Contact Email\r\n"),
|
||||||
call(f"cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,, {linesep}"),
|
call(f"cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,, \r\n"),
|
||||||
call(f"ddomain3.gov,Federal,Armed Forces Retirement Home,,,, {linesep}"),
|
call(f"ddomain3.gov,Federal,Armed Forces Retirement Home,,,, \r\n"),
|
||||||
call(f"adomain2.gov,Interstate,,,,, {linesep}"),
|
call(f"adomain2.gov,Interstate,,,,, \r\n"),
|
||||||
]
|
]
|
||||||
fake_open = mock_open()
|
fake_open = mock_open()
|
||||||
# We don't actually want to write anything for a test case,
|
# We don't actually want to write anything for a test case,
|
||||||
|
@ -147,9 +146,27 @@ class CsvReportsTest(TestCase):
|
||||||
# Check that the response contains what we expect
|
# Check that the response contains what we expect
|
||||||
file_content = b"".join(response.streaming_content).decode("utf-8")
|
file_content = b"".join(response.streaming_content).decode("utf-8")
|
||||||
expected_file_content = (
|
expected_file_content = (
|
||||||
f"Domain name,Domain type,Agency,Organization name,City,State,Security Contact Email{linesep}"
|
f"Domain name,Domain type,Agency,Organization name,City,State,Security Contact Email\r\n"
|
||||||
f"cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,, {linesep}"
|
f"cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,,\r\n"
|
||||||
f"ddomain3.gov,Federal,Armed Forces Retirement Home,,,, {linesep}"
|
f"ddomain3.gov,Federal,Armed Forces Retirement Home,,,,"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(file_content, expected_file_content)
|
||||||
|
|
||||||
|
def test_load_full_report(self):
|
||||||
|
"""Tests the current-federal api link"""
|
||||||
|
self.maxDiff = None
|
||||||
|
request = self.factory.get("/fake-path")
|
||||||
|
response = get_current_federal(request, file_path="registrar/tests/data/fake_current_full.csv")
|
||||||
|
# Check that the response has status code 200
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
# Check that the response contains what we expect
|
||||||
|
file_content = b"".join(response.streaming_content).decode("utf-8")
|
||||||
|
expected_file_content = (
|
||||||
|
f"Domain name,Domain type,Agency,Organization name,City,State,Security Contact Email\r\n"
|
||||||
|
f"cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,,\r\n"
|
||||||
|
f"ddomain3.gov,Federal,Armed Forces Retirement Home,,,,\r\n"
|
||||||
|
f"adomain2.gov,Interstate,,,,,"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(file_content, expected_file_content)
|
self.assertEqual(file_content, expected_file_content)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue