mirror of
https://github.com/etnguyen03/tjdests.git
synced 2025-04-20 17:50:16 -04:00
test: fix tests
This commit is contained in:
parent
beb546fdf2
commit
64e71aaa0c
|
@ -45,7 +45,7 @@ def accept_tos_view(request: HttpRequest) -> HttpResponse:
|
||||||
form = TOSForm(request.POST)
|
form = TOSForm(request.POST)
|
||||||
|
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
accept_tos = form.cleaned_data.get("accept_tos")
|
accept_tos: bool = form.cleaned_data.get("accept_tos")
|
||||||
request.user.accepted_terms = accept_tos
|
request.user.accepted_terms = accept_tos
|
||||||
request.user.set_password(form.cleaned_data.get("password"))
|
request.user.set_password(form.cleaned_data.get("password"))
|
||||||
request.user.save()
|
request.user.save()
|
||||||
|
|
|
@ -320,11 +320,6 @@ class DestinationsTest(TJDestsTestCase):
|
||||||
self.assertIn(college, response.context["object_list"])
|
self.assertIn(college, response.context["object_list"])
|
||||||
self.assertIn(college2, response.context["object_list"])
|
self.assertIn(college2, response.context["object_list"])
|
||||||
|
|
||||||
response = self.client.get(reverse("destinations:colleges"), data={"q": "1234"})
|
|
||||||
self.assertEqual(200, response.status_code)
|
|
||||||
self.assertEqual(1, response.context["object_list"].count())
|
|
||||||
self.assertIn(college2, response.context["object_list"])
|
|
||||||
|
|
||||||
def test_import_ceeb_command(self):
|
def test_import_ceeb_command(self):
|
||||||
# First, just call the command
|
# First, just call the command
|
||||||
with self.assertRaises(CommandError):
|
with self.assertRaises(CommandError):
|
||||||
|
@ -333,10 +328,10 @@ class DestinationsTest(TJDestsTestCase):
|
||||||
College.objects.all().delete()
|
College.objects.all().delete()
|
||||||
|
|
||||||
file_contents = (
|
file_contents = (
|
||||||
"CEEB,College Name,City,State\n"
|
"Country,College,City,State\n"
|
||||||
"1234,Test University,Alexandria,VA\n"
|
"UNITED STATES,Test University,Alexandria,VA\n"
|
||||||
"1235,University of Test,Arlington,VA\n"
|
"UNITED STATES,University of Test,Arlington,VA\n"
|
||||||
"INTL,University of Abroad,ExampleCity,RANDOMCOUNTRY"
|
"RANDOMCOUNTRY,University of Abroad,ExampleCity,Example"
|
||||||
)
|
)
|
||||||
with patch(
|
with patch(
|
||||||
"tjdests.apps.destinations.management.commands.import_ceeb.open",
|
"tjdests.apps.destinations.management.commands.import_ceeb.open",
|
||||||
|
@ -362,7 +357,7 @@ class DestinationsTest(TJDestsTestCase):
|
||||||
1,
|
1,
|
||||||
College.objects.filter(
|
College.objects.filter(
|
||||||
name="University of Abroad",
|
name="University of Abroad",
|
||||||
location="ExampleCity, RANDOMCOUNTRY",
|
location="ExampleCity, Example, RANDOMCOUNTRY",
|
||||||
).count(),
|
).count(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -370,11 +365,11 @@ class DestinationsTest(TJDestsTestCase):
|
||||||
# But let's add a few more...
|
# But let's add a few more...
|
||||||
|
|
||||||
file_contents = (
|
file_contents = (
|
||||||
"CEEB,College Name,City,State\n"
|
"Country,College,City,State\n"
|
||||||
"1234,Test University,Alexandria,VA\n"
|
"UNITED STATES,Test University,Alexandria,VA\n"
|
||||||
"1235,University of Test,Arlington,VA\n"
|
"UNITED STATES,University of Test,Arlington,VA\n"
|
||||||
"INTL,University of Abroad,ExampleCity,RANDOMCOUNTRY\n"
|
"RANDOMCOUNTRY,University of Abroad,ExampleCity,RANDOM\n"
|
||||||
"INTL,University of Abroad in CityTwo,CityTwo,RANDOMCOUNTRY\n"
|
"RANDOMCOUNTRY,University of Abroad in CityTwo,CityTwo,RANDOM\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -401,13 +396,13 @@ class DestinationsTest(TJDestsTestCase):
|
||||||
1,
|
1,
|
||||||
College.objects.filter(
|
College.objects.filter(
|
||||||
name="University of Abroad",
|
name="University of Abroad",
|
||||||
location="ExampleCity, RANDOMCOUNTRY",
|
location="ExampleCity, RANDOM, RANDOMCOUNTRY",
|
||||||
).count(),
|
).count(),
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1,
|
1,
|
||||||
College.objects.filter(
|
College.objects.filter(
|
||||||
name="University of Abroad in CityTwo",
|
name="University of Abroad in CityTwo",
|
||||||
location="CityTwo, RANDOMCOUNTRY",
|
location="CityTwo, RANDOM, RANDOMCOUNTRY",
|
||||||
).count(),
|
).count(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -89,6 +89,7 @@ class TestScoreUpdateView(
|
||||||
class TestScoreDeleteView(
|
class TestScoreDeleteView(
|
||||||
LoginRequiredMixin, SuccessMessageMixin, UserPassesTestMixin, DeleteView
|
LoginRequiredMixin, SuccessMessageMixin, UserPassesTestMixin, DeleteView
|
||||||
):
|
):
|
||||||
|
object: TestScore
|
||||||
model = TestScore
|
model = TestScore
|
||||||
template_name = "profile/testscore_delete.html"
|
template_name = "profile/testscore_delete.html"
|
||||||
success_message = "Test score deleted successfully."
|
success_message = "Test score deleted successfully."
|
||||||
|
@ -165,6 +166,7 @@ class DecisionUpdateView(
|
||||||
class DecisionDeleteView(
|
class DecisionDeleteView(
|
||||||
LoginRequiredMixin, SuccessMessageMixin, UserPassesTestMixin, DeleteView
|
LoginRequiredMixin, SuccessMessageMixin, UserPassesTestMixin, DeleteView
|
||||||
):
|
):
|
||||||
|
object: Decision
|
||||||
model = Decision
|
model = Decision
|
||||||
template_name = "profile/decision_delete.html"
|
template_name = "profile/decision_delete.html"
|
||||||
success_message = "Decision deleted successfully."
|
success_message = "Decision deleted successfully."
|
||||||
|
|
Loading…
Reference in New Issue
Block a user