def setUp(self): self.created_ticket_name = self.random_name self.ticket = Ticket.create(self.email, self.first_name, self.last_name, self.created_ticket_name, self.ticket_text) self.ticket.update(Name=self.NEW_NAME) self.ticket = Ticket(self.ticket.id)
def setUp(self): self.created_ticket_name = self.random_name self.ticket = Ticket.create(self.email, self.first_name, self.last_name, self.created_ticket_name, self.ticket_text) self.assertEqual(len(Ticket.search(Name=self.created_ticket_name)), 1) self.contacts = self.ticket.contacts self.ticket.delete() self.found_tickets = Ticket.search(Name=self.created_ticket_name)
class TestUpdateTicket(TestTicket): NEW_NAME = 'new name' def setUp(self): self.created_ticket_name = self.random_name self.ticket = Ticket.create(self.email, self.first_name, self.last_name, self.created_ticket_name, self.ticket_text) self.ticket.update(Name=self.NEW_NAME) self.ticket = Ticket(self.ticket.id) def test_ticket_name_is_updated(self): self.assertEqual(self.ticket.Name, self.NEW_NAME) def tearDown(self): contacts = self.ticket.contacts self.ticket.delete() [c.delete() for c in contacts]
class TestCreateTicket(TestTicket): def setUp(self): self.returned_ticket = Ticket.create(self.email, self.first_name, self.last_name, self.ticket_name, self.ticket_text) self.ticket = Ticket(self.returned_ticket.id) self.contact = Contact.get(self.email) def test_ticket_is_created(self): self.assertEqual(self.ticket.Name, self.ticket_name) def test_ticket_description_is_set(self): description = self.ticket.get_description() self.assertEqual(description, self.ticket_text) def test_new_contact_is_created(self): self.assertEqual(self.contact.FirstName, self.first_name) self.assertEqual(self.contact.LastName, self.last_name) self.assertEqual(self.contact.Email, self.email) def test_ticket_associated_with_contact(self): self.assertEqual(len(self.ticket.contacts), 1) contact = self.ticket.contacts[0] self.assertEqual(contact.FirstName, self.first_name) self.assertEqual(contact.Email, self.email) def test_created_ticket_is_returned(self): self.assertEqual(self.returned_ticket.id, self.ticket.id) self.assertEqual(self.returned_ticket.Name, self.ticket.Name) def test_datetimes_are_converted_to_datetime_type(self): self.assertIsInstance(self.returned_ticket.DateCreated, datetime) self.assertIsInstance(self.returned_ticket.DateModified, datetime) def tearDown(self): self.ticket.delete() self.contact.delete()
def setUp(self): # Make sure contact with such email doesn't exist. contact = Contact.get(self.email) self.assertIsNone(contact) # Create contact manually. self.contact = Contact.create(self.email, FirstName=self.first_name, LastName=self.last_name) # Create ticket from same email as just created contact. self.ticket = Ticket.create(self.email, self.first_name, self.last_name, self.ticket_name, self.ticket_text) self.ticket_contact = Contact.get(self.email)
def test_actions_querylist(self): self.response.content = """<Actions> <Action> <ID>ActionID</ID> <TicketID>ID</TicketID> <Name>Description</Name> </Action> </Actions>""" ticket = Ticket(data=self.ticket_element) actions = ticket.actions description_action = actions.get(Name='Description') self.assertIsInstance(description_action, Action) self.assertEqual(description_action.id, 'ActionID') self.assertEqual(description_action.ticket_id, 'ID')
def test_actions_property(self): self.response.content = """<Actions> <Action> <ID>ActionID</ID> <TicketID>ID</TicketID> <Name>Description</Name> </Action> </Actions>""" ticket = Ticket(data=self.ticket_element) actions = ticket.actions self.assertEqual(len(actions), 1) self.assertIsInstance(actions[0], Action) self.assertEqual(actions[0].id, 'ActionID') self.assertEqual(actions[0].ticket_id, 'ID') self.assertEqual(actions[0].Name, 'Description')
def setUp(self): self.created_ticket_name = self.random_name self.ticket = Ticket.create(self.email, self.first_name, self.last_name, self.created_ticket_name, self.ticket_text) self.found_tickets = Ticket.search(Name=self.created_ticket_name)
def setUp(self): self.returned_ticket = Ticket.create(self.email, self.first_name, self.last_name, self.ticket_name, self.ticket_text) self.ticket = Ticket(self.returned_ticket.id) self.contact = Contact.get(self.email)
def test_getattr(self): ticket_element = E.Ticket(E.TicketID('ID'), E.Field2('Test')) ticket = Ticket(data=ticket_element) self.assertEqual(ticket.Field2, 'Test')
def test_initialisation_with_data(self): ticket = Ticket(data=self.ticket_element) self.assertEqual(ticket.id, 'ID')
def test_initialisation_with_id(self): self.response.content = '<Ticket><TicketID>ID</TicketID></Ticket>' ticket = Ticket(ticket_id='ID') self.assertEqual(ticket.id, 'ID')