def setUp(self): self.user = UserFactory(username="******", first_name="Bart", last_name="Simpson") # self.user2 = UserFactory(is_staff=True) self.user2 = UserFactory( username="******", first_name="Barney", last_name="Gumble", password="******", is_staff=True, ) self.user3 = UserFactory(username="******", first_name="Homer", last_name="Simpson") adminGrp, created = Group.objects.get_or_create(name="admin") self.user2.groups.add(adminGrp) self.status = "new" self.ticket_type = "bug" self.description = "There is something wrong." self.priority = 3 self.ticket = TicketFactory( submitted_by=self.user, status=self.status, ticket_type=self.ticket_type, description=self.description, priority=self.priority, )
def setUp(self): """we will need some users, a ticket, and some private and public comments. """ self.user1 = UserFactory(username="******") self.user2 = UserFactory(username="******") self.user3 = UserFactory(username="******") # make user 2 an administrator adminGrp, created = Group.objects.get_or_create(name="admin") self.user2.groups.add(adminGrp) self.ticket = TicketFactory(submitted_by=self.user1) self.msg1 = "This is a public message posted by George" self.comment1 = FollowUpFactory( ticket=self.ticket, submitted_by=self.user1, comment=self.msg1 ) self.msg2 = "This is a public message posted by Homer" self.comment2 = FollowUpFactory( ticket=self.ticket, submitted_by=self.user2, comment=self.msg2 ) self.msg3 = "This is a PRIVATE message posted by George" self.comment3 = FollowUpFactory( ticket=self.ticket, submitted_by=self.user1, comment=self.msg3, private=True ) self.msg4 = "This is a PRIVATE message posted by Homer" self.comment4 = FollowUpFactory( ticket=self.ticket, submitted_by=self.user2, comment=self.msg4, private=True )
def setUp(self): """ """ """create a user, some languages and three snippets""" self.user1 = UserFactory(username="******") self.ticket1 = TicketFactory(submitted_by=self.user1) self.ticket2 = TicketFactory(submitted_by=self.user1) self.ticket3 = TicketFactory(submitted_by=self.user1)
def setUp(self): self.user = UserFactory() self.user2 = UserFactory(is_staff=True) self.user3 = UserFactory(username="******", is_staff=True) adminGrp, created = Group.objects.get_or_create(name="admin") self.user2.groups.add(adminGrp) self.ticket = TicketFactory(submitted_by=self.user)
def setUp(self): self.user = UserFactory() self.user2 = UserFactory(is_staff=True) self.user3 = UserFactory(username="******") adminGrp, created = Group.objects.get_or_create(name="admin") self.user2.groups.add(adminGrp) self.ticket = TicketFactory() self.ticket2 = TicketFactory(description="This is a duplicate")
def setUp(self): self.user = UserFactory(username="******", first_name="Bart", last_name="Simpson") self.user2 = UserFactory(username="******", first_name="Barney", last_name="Gumble", is_staff=True) adminGrp, created = Group.objects.get_or_create(name="admin") self.user2.groups.add(adminGrp) self.ticket = TicketFactory()
def setUp(self): self.user1 = UserFactory(first_name="Homer", last_name="Simpson") desc = "This ticket is new. findme." self.ticket1 = TicketFactory( status="new", submitted_by=self.user1, ticket_type="feature", title=desc, description=desc, ) desc = "This ticket is accepted." self.ticket2 = TicketFactory(status="accepted", submitted_by=self.user1, title=desc, description=desc) desc = "This ticket is assigned." self.ticket3 = TicketFactory( status="assigned", ticket_type="feature", title=desc, description=desc, assigned_to=self.user1, ) desc = "This ticket is reopened. findme." self.ticket4 = TicketFactory(status="reopened", title=desc, description=desc) desc = "This ticket is closed. findme" self.ticket5 = TicketFactory(status="closed", title=desc, description=desc) desc = "This ticket is a duplicate." self.ticket6 = TicketFactory(status="duplicate", title=desc, description=desc) desc = "This ticket is split." self.ticket7 = TicketFactory(status="split", title=desc, description=desc) # TODO - activate for inactive: desc = "This ticket is inactive. findme" self.ticket8 = TicketFactory(active=False, title=desc, description=desc)
def setUp(self): self.user = UserFactory() desc = "This is the first ticket" self.ticket = TicketFactory(submitted_by=self.user, description=desc) desc = "This is a duplicate of ticket1" self.ticket2 = TicketFactory(description=desc) desc = "This will be the 1st child of ticket1" self.ticket3 = TicketFactory(submitted_by=self.user, description=desc, parent=self.ticket) # flag ticket 2 as a duplicate of the first self.ticket2.duplicate_of(self.ticket.id)
def setUp(self): self.user = UserFactory(username="******", password="******") self.ticket = TicketFactory()
class ProjectTaggingTestCase(TestCase): """Verify that the projects can be tagged with keywords in the project form.""" def setUp(self): """ """ """create a user, some languages and three snippets""" self.user1 = UserFactory(username="******") self.ticket1 = TicketFactory(submitted_by=self.user1) self.ticket2 = TicketFactory(submitted_by=self.user1) self.ticket3 = TicketFactory(submitted_by=self.user1) def tearDown(self): """ """ self.ticket2.delete() self.ticket1.delete() self.user1.delete() def test_tags_in_snippet_details_view(self): """verify that the tags associated with a snippet appear on its details (and not on others)""" # assign some tags to project1 tags = ["red", "blue", "green", "yellow"] tags.sort() for tag in tags: self.ticket1.tags.add(tag) # ======================= # verify that the tags are associated with that project tags_back = self.ticket1.tags.all().order_by("name") self.assertQuerysetEqual(tags_back, tags, lambda a: str(a.name)) self.assertEqual(tags_back.count(), len(tags)) # verify that the tag appears as a hyperlink on the details # page for this project: response = self.client.get(reverse("tickets:ticket_detail", args=(self.ticket1.pk, )), user=self.user1) self.assertEqual(response.status_code, 200) linkstring_base = '<a href="{}">{}</a>' for tag in tags: tag_url = reverse("tickets:tickets_tagged_with", args=(tag, )) linkstring = linkstring_base.format(tag_url, tag) self.assertContains(response, linkstring) # ======================= # verify that the tags are NOT associated with project2 response = self.client.get(reverse("tickets:ticket_detail", args=(self.ticket2.pk, )), user=self.user1) self.assertEqual(response.status_code, 200) linkstring_base = '<a href="{}">{}</a>' for tag in tags: tag_url = reverse("tickets:tickets_tagged_with", args=(tag, )) linkstring = linkstring_base.format(tag_url, tag) self.assertNotContains(response, linkstring) def test_tags_ticket_list_view(self): """This test verifies that the url for 'tickets_tagged_with' returns just the tickets with that tag and includes an informative heading. Tags that do not have the specified tag, should not be included in the response. """ # tickets 1 and 2 will be tagged, ticket three is not: tags = ["red", "blue"] tags.sort() for tag in tags: self.ticket1.tags.add(tag) self.ticket2.tags.add(tag) # ======================= # verify that the tags are associated with that ticket tags_back = self.ticket1.tags.all().order_by("name") self.assertQuerysetEqual(tags_back, tags, lambda a: str(a.name)) tags_back = self.ticket2.tags.all().order_by("name") self.assertQuerysetEqual(tags_back, tags, lambda a: str(a.name)) # load the page associated with tag 1 and verify that it # contains records for tickett 1 and 2 (as hyperlinks), but # not ticket 3 response = self.client.get(reverse("tickets:tickets_tagged_with", args=(tags[0], )), user=self.user1) self.assertEqual(response.status_code, 200) self.assertTemplateUsed("tickets\ticket_list.html") msg = "Tickets Tagged with '{}'".format(tags[0]) self.assertContains(response, msg) link_base = '<td><a href="{}">{}</a></td>' ticket_list = [self.ticket1, self.ticket2, self.ticket3] for ticket in ticket_list[:2]: url = link_base.format(ticket.get_absolute_url(), ticket.id) self.assertContains(response, url, html=True) url = link_base.format(self.ticket3.get_absolute_url(), self.ticket3.id) self.assertNotContains(response, url, html=True) # ==================== # navigate to the whole ticket list and verify that it contain # records for all three tickets response = self.client.get(reverse("tickets:ticket_list"), user=self.user1) self.assertEqual(response.status_code, 200) for ticket in ticket_list: url = link_base.format(ticket.get_absolute_url(), ticket.id) self.assertContains(response, url, html=True)