mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 09:37:03 +02:00
Fix failing tests
This commit is contained in:
parent
758c645943
commit
54b6b525b5
6 changed files with 37 additions and 14 deletions
|
@ -4,7 +4,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||||
from django.http.response import HttpResponseRedirect
|
from django.http.response import HttpResponseRedirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from .models import User, UserProfile, DomainApplication, Website
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
class AuditedAdmin(admin.ModelAdmin):
|
class AuditedAdmin(admin.ModelAdmin):
|
||||||
|
@ -26,7 +26,7 @@ class UserProfileInline(admin.StackedInline):
|
||||||
|
|
||||||
"""Edit a user's profile on the user page."""
|
"""Edit a user's profile on the user page."""
|
||||||
|
|
||||||
model = UserProfile
|
model = models.UserProfile
|
||||||
|
|
||||||
|
|
||||||
class MyUserAdmin(UserAdmin):
|
class MyUserAdmin(UserAdmin):
|
||||||
|
@ -36,6 +36,24 @@ class MyUserAdmin(UserAdmin):
|
||||||
inlines = [UserProfileInline]
|
inlines = [UserProfileInline]
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(User, MyUserAdmin)
|
class HostIPInline(admin.StackedInline):
|
||||||
admin.site.register(DomainApplication, AuditedAdmin)
|
|
||||||
admin.site.register(Website, AuditedAdmin)
|
"""Edit an ip address on the host page."""
|
||||||
|
|
||||||
|
model = models.HostIP
|
||||||
|
|
||||||
|
|
||||||
|
class MyHostAdmin(AuditedAdmin):
|
||||||
|
|
||||||
|
"""Custom host admin class to use our inlines."""
|
||||||
|
|
||||||
|
inlines = [HostIPInline]
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(models.User, MyUserAdmin)
|
||||||
|
admin.site.register(models.Contact, AuditedAdmin)
|
||||||
|
admin.site.register(models.DomainApplication, AuditedAdmin)
|
||||||
|
admin.site.register(models.Domain, AuditedAdmin)
|
||||||
|
admin.site.register(models.Host, MyHostAdmin)
|
||||||
|
admin.site.register(models.Nameserver, MyHostAdmin)
|
||||||
|
admin.site.register(models.Website, AuditedAdmin)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 4.1.3 on 2022-11-17 13:46
|
# Generated by Django 4.1.3 on 2022-11-28 19:07
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
|
@ -43,7 +43,6 @@ class Migration(migrations.Migration):
|
||||||
default=False,
|
default=False,
|
||||||
help_text="Domain is live in the registry",
|
help_text="Domain is live in the registry",
|
||||||
max_length=50,
|
max_length=50,
|
||||||
protected=True,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
("owners", models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
|
("owners", models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
|
||||||
|
@ -77,6 +76,7 @@ class Migration(migrations.Migration):
|
||||||
models.ForeignKey(
|
models.ForeignKey(
|
||||||
help_text="Domain to which this host belongs",
|
help_text="Domain to which this host belongs",
|
||||||
on_delete=django.db.models.deletion.PROTECT,
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="host",
|
||||||
to="registrar.domain",
|
to="registrar.domain",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -133,6 +133,7 @@ class Migration(migrations.Migration):
|
||||||
models.ForeignKey(
|
models.ForeignKey(
|
||||||
help_text="Host to which this IP address belongs",
|
help_text="Host to which this IP address belongs",
|
||||||
on_delete=django.db.models.deletion.PROTECT,
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
related_name="ip",
|
||||||
to="registrar.host",
|
to="registrar.host",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -224,7 +224,8 @@ class Domain(TimeStampedModel):
|
||||||
(False, "No"),
|
(False, "No"),
|
||||||
],
|
],
|
||||||
default=False,
|
default=False,
|
||||||
protected=True,
|
# TODO: how to edit models in Django admin if protected = True
|
||||||
|
protected=False,
|
||||||
help_text="Domain is live in the registry",
|
help_text="Domain is live in the registry",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -211,8 +211,8 @@ class DomainApplication(TimeStampedModel):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
try:
|
try:
|
||||||
if self.requested_domain and self.requested_domain.website:
|
if self.requested_domain and self.requested_domain.name:
|
||||||
return self.requested_domain.website
|
return self.requested_domain.name
|
||||||
else:
|
else:
|
||||||
return f"{self.status} application created by {self.creator}"
|
return f"{self.status} application created by {self.creator}"
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for application in domain_applications %}
|
{% for application in domain_applications %}
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ application.requested_domain.website }}</th>
|
<th>{{ application.requested_domain.name }}</th>
|
||||||
<td>{{ application.status }}</td>
|
<td>{{ application.status }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -5,9 +5,11 @@ from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
from django_webtest import WebTest # type: ignore
|
from django_webtest import WebTest # type: ignore
|
||||||
|
|
||||||
from registrar.models import DomainApplication, Website
|
from registrar.models import DomainApplication, Domain
|
||||||
from registrar.forms.application_wizard import TITLES
|
from registrar.forms.application_wizard import TITLES
|
||||||
|
|
||||||
|
from .common import less_console_noise
|
||||||
|
|
||||||
|
|
||||||
class TestViews(TestCase):
|
class TestViews(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -58,7 +60,7 @@ class LoggedInTests(TestWithUser):
|
||||||
def test_home_lists_domain_applications(self):
|
def test_home_lists_domain_applications(self):
|
||||||
response = self.client.get("/")
|
response = self.client.get("/")
|
||||||
self.assertNotContains(response, "igorville.gov")
|
self.assertNotContains(response, "igorville.gov")
|
||||||
site = Website.objects.create(website="igorville.gov")
|
site = Domain.objects.create(name="igorville.gov")
|
||||||
application = DomainApplication.objects.create(
|
application = DomainApplication.objects.create(
|
||||||
creator=self.user, requested_domain=site
|
creator=self.user, requested_domain=site
|
||||||
)
|
)
|
||||||
|
@ -307,7 +309,8 @@ class FormTests(TestWithUser, WebTest):
|
||||||
# following this redirect is a GET request, so include the cookie
|
# following this redirect is a GET request, so include the cookie
|
||||||
# here too.
|
# here too.
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
final_result = review_result.follow()
|
with less_console_noise():
|
||||||
|
final_result = review_result.follow()
|
||||||
self.assertContains(final_result, "Thank you for your domain request")
|
self.assertContains(final_result, "Thank you for your domain request")
|
||||||
|
|
||||||
def test_application_form_conditional_federal(self):
|
def test_application_form_conditional_federal(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue