Skip to content

Commit

Permalink
Fix Ticket Tests for Django 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TravelTimN committed Feb 8, 2020
1 parent ebc9b8e commit 8450f72
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions project/tickets/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,22 @@ def setUp(self):
description="Test description on new Feature Ticket",
ticket_status=TicketStatus(id=1),
ticket_type=TicketType(id=2)).save()
self.client.post(
"/accounts/register/",
{"email": "Test@Email.com",
"username": "TestUser",
"first_name": "TestFirst",
"last_name": "TestLast",
"password1": "Passw0rd",
"password2": "Passw0rd"})
""" the following 8 lines were for Django 1.11 """
# self.client.post(
# "/accounts/register/",
# {"email": "Test@Email.com",
# "username": "TestUser",
# "first_name": "TestFirst",
# "last_name": "TestLast",
# "password1": "Passw0rd",
# "password2": "Passw0rd"})
"""
the following 3 lines are for Django 2.2
(create user and log user in)
"""
self.user = User.objects.create_user(
username="TestUser", password="Passw0rd")
self.client.login(username="TestUser", password="Passw0rd")

def test_tickets_view_all(self):
page = self.client.get("/tickets/")
Expand Down Expand Up @@ -134,11 +142,12 @@ def test_tickets_edit_saved(self):

def test_tickets_delete(self):
ticket = Ticket.objects.filter(title="Test Bug")[0]
response = self.client.get(
"/tickets/{0}".format(ticket.pk), follow=True)
results = Ticket.objects.filter(
description="Test description on new Bug Ticket").count()
self.assertEqual(results, 1)
""" the following 5 lines serve no actual purpose """
# response = self.client.get(
# "/tickets/{0}".format(ticket.pk), follow=True)
# results = Ticket.objects.filter(
# description="Test description on new Bug Ticket").count()
# self.assertEqual(results, 1)
self.client.get("/tickets/delete/{0}".format(ticket.pk), follow=True)
tickets_delete = Ticket.objects.filter(title="Test Bug").count()
self.assertEqual(tickets_delete, 0)

0 comments on commit 8450f72

Please sign in to comment.