mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 18:39:21 +02:00
updated tests
This commit is contained in:
parent
a9aa8b16ef
commit
5a896ac369
3 changed files with 28 additions and 4 deletions
|
@ -1333,18 +1333,16 @@ class DomainRequest(TimeStampedModel):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
"""the following converted_ property methods get their respective field names from portfolio, if the domain request has a portfolio. if it does not, it will get the info from the model itself."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def converted_organization_name(self):
|
def converted_organization_name(self):
|
||||||
""" "returns the organization field if the domain request is in a portfolio
|
|
||||||
otherwise it returns the organization name from the domain request object itself"""
|
|
||||||
if self.portfolio:
|
if self.portfolio:
|
||||||
return self.portfolio.organization_name
|
return self.portfolio.organization_name
|
||||||
return self.organization_name
|
return self.organization_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def converted_generic_org_type(self):
|
def converted_generic_org_type(self):
|
||||||
""" "returns the organization type if the domain request is in a portfolio
|
|
||||||
otherwise it returns the organization type from the domain request object itself"""
|
|
||||||
if self.portfolio:
|
if self.portfolio:
|
||||||
return self.portfolio.organization_type
|
return self.portfolio.organization_type
|
||||||
return self.generic_org_type
|
return self.generic_org_type
|
||||||
|
|
|
@ -576,6 +576,8 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
response = self.client.get("/admin/registrar/domainrequest/?generic_org_type__exact=federal")
|
response = self.client.get("/admin/registrar/domainrequest/?generic_org_type__exact=federal")
|
||||||
# There are 2 template references to Federal (4) and two in the results data
|
# There are 2 template references to Federal (4) and two in the results data
|
||||||
# of the request
|
# of the request
|
||||||
|
self.assertContains(response, "Federal", count=48)
|
||||||
|
self.assertContains(response, "Converted federal", count=4)
|
||||||
# This may be a bit more robust
|
# This may be a bit more robust
|
||||||
self.assertContains(response, '<td class="field-converted_generic_org_type">federal</td>', count=1)
|
self.assertContains(response, '<td class="field-converted_generic_org_type">federal</td>', count=1)
|
||||||
# Now let's make sure the long description does not exist
|
# Now let's make sure the long description does not exist
|
||||||
|
|
|
@ -14,6 +14,7 @@ from registrar.models import (
|
||||||
DraftDomain,
|
DraftDomain,
|
||||||
FederalAgency,
|
FederalAgency,
|
||||||
AllowedEmail,
|
AllowedEmail,
|
||||||
|
Portfolio,
|
||||||
)
|
)
|
||||||
|
|
||||||
import boto3_mocking
|
import boto3_mocking
|
||||||
|
@ -95,6 +96,7 @@ class TestDomainRequest(TestCase):
|
||||||
DomainRequest.objects.all().delete()
|
DomainRequest.objects.all().delete()
|
||||||
DraftDomain.objects.all().delete()
|
DraftDomain.objects.all().delete()
|
||||||
Domain.objects.all().delete()
|
Domain.objects.all().delete()
|
||||||
|
Portfolio.objects.all().delete()
|
||||||
User.objects.all().delete()
|
User.objects.all().delete()
|
||||||
self.mock_client.EMAILS_SENT.clear()
|
self.mock_client.EMAILS_SENT.clear()
|
||||||
|
|
||||||
|
@ -1045,3 +1047,25 @@ class TestDomainRequest(TestCase):
|
||||||
status=DomainRequest.DomainRequestStatus.STARTED, name="no-others.gov", has_other_contacts=False
|
status=DomainRequest.DomainRequestStatus.STARTED, name="no-others.gov", has_other_contacts=False
|
||||||
)
|
)
|
||||||
self.assertEquals(domain_request.has_other_contacts(), False)
|
self.assertEquals(domain_request.has_other_contacts(), False)
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
|
def test_converted_type(self):
|
||||||
|
"""test that new property fields works as expected to pull domain req info such as fed agency, generic org type, and others from portfolio"""
|
||||||
|
fed_agency = FederalAgency.objects.filter(agency="Non-Federal Agency").first()
|
||||||
|
portfolio = Portfolio.objects.create(
|
||||||
|
organization_name="Test Portfolio",
|
||||||
|
creator=self.dummy_user_2,
|
||||||
|
federal_agency=fed_agency,
|
||||||
|
organization_type=DomainRequest.OrganizationChoices.FEDERAL,
|
||||||
|
)
|
||||||
|
|
||||||
|
domain_request = completed_domain_request(name="domainre1.gov", portfolio=portfolio)
|
||||||
|
|
||||||
|
self.assertEqual(portfolio.organization_type, domain_request.converted_generic_org_type)
|
||||||
|
self.assertEqual(portfolio.federal_agency, domain_request.converted_federal_agency)
|
||||||
|
|
||||||
|
domain_request2 = completed_domain_request(
|
||||||
|
name="domainreq2.gov", federal_agency=fed_agency, generic_org_type=DomainRequest.OrganizationChoices.TRIBAL
|
||||||
|
)
|
||||||
|
self.assertEqual(domain_request2.generic_org_type, domain_request2.converted_generic_org_type)
|
||||||
|
self.assertEqual(domain_request2.federal_agency, domain_request2.converted_federal_agency)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue