Пример #1
0
        def test_ticket_update_attrs_by_number(self):
            t = Ticket(State='new',
                       Priority='3 normal',
                       Queue='Support',
                       Title='Problem test',
                       CustomerUser='******',
                       Type='Divers')
            a = Article(Subject='UnitTest',
                        Body='bla',
                        Charset='UTF8',
                        MimeType='text/plain')
            t_id, t_number = self.c.ticket_create(t, a)

            t = Ticket(Title='Foubar')
            upd_tid, upd_tnumber = self.c.ticket_update(ticket_number=t_number,
                                                        ticket=t)
            self.assertIsInstance(upd_tid, int)
            self.assertIsInstance(upd_tnumber, int)
            self.assertTrue(len(str(upd_tnumber)) >= 12)

            self.assertEqual(upd_tid, t_id)
            self.assertEqual(upd_tnumber, t_number)

            upd_t = self.c.ticket_get(t_id)
            self.assertEqual(upd_t.Title, 'Foubar')
            self.assertEqual(upd_t.Queue, 'Support')
Пример #2
0
    def test_ticket_to_xml(self):
        t = Ticket(State='open', Priority='3 normal', Queue='Support')
        xml = t.to_xml()
        xml_childs = xml.getchildren()

        xml_childs_dict = {i.tag: i.text for i in xml_childs}

        self.assertEqual(xml.tag, 'Ticket')
        self.assertEqual(len(xml_childs), 3)
        self.assertEqual(xml_childs_dict['State'], 'open')
        self.assertEqual(xml_childs_dict['Priority'], '3 normal')
        self.assertEqual(xml_childs_dict['Queue'], 'Support')
Пример #3
0
    def test_ticket_to_xml(self):
        t = Ticket(State='open', Priority='3 normal', Queue='Support')
        xml = t.to_xml()
        xml_childs = xml.getchildren()

        xml_childs_dict = {i.tag: i.text for i in xml_childs}

        self.assertEqual(xml.tag, 'Ticket')
        self.assertEqual(len(xml_childs), 3)
        self.assertEqual(xml_childs_dict['State'], 'open')
        self.assertEqual(xml_childs_dict['Priority'], '3 normal')
        self.assertEqual(xml_childs_dict['Queue'], 'Support')
Пример #4
0
        def test_ticket_update_new_article(self):
            t = Ticket(State='new',
                       Priority='3 normal',
                       Queue='Support',
                       Title='Problem test',
                       CustomerUser='******',
                       Type='Divers')
            a = Article(Subject='UnitTest',
                        Body='bla',
                        Charset='UTF8',
                        MimeType='text/plain')
            t_id, t_number = self.c.ticket_create(t, a)

            a2 = Article(Subject='UnitTest2',
                         Body='bla',
                         Charset='UTF8',
                         MimeType='text/plain')

            a3 = Article(Subject='UnitTest3',
                         Body='bla',
                         Charset='UTF8',
                         MimeType='text/plain')

            self.c.ticket_update(t_id, article=a2)
            self.c.ticket_update(t_id, article=a3)

            t_upd = self.c.ticket_get(t_id, get_articles=True)
            arts_upd = t_upd.articles()
            self.assertIsInstance(arts_upd, list)
            self.assertEqual(len(arts_upd), 4)
            self.assertEqual(arts_upd[0].Subject, 'UnitTest')
            # article 1 is an auto response
            self.assertEqual(arts_upd[2].Subject, 'UnitTest2')
            self.assertEqual(arts_upd[3].Subject, 'UnitTest3')
Пример #5
0
 def test_ticket_from_xml_with_articles(self):
     xml = etree.fromstring(SAMPLE_TICKET_W_ARTICLES)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')
     articles = t.articles()
     self.assertIsInstance(articles, list)
     self.assertEqual(len(articles), 1)
     self.assertIsInstance(articles[0], Article)
     self.assertEqual(articles[0].AgeTimeUnix, 863982)
Пример #6
0
 def test_ticket_from_xml_with_articles(self):
     xml = etree.fromstring(SAMPLE_TICKET_W_ARTICLES)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')
     articles = t.articles()
     self.assertIsInstance(articles, list)
     self.assertEqual(len(articles), 1)
     self.assertIsInstance(articles[0], Article)
     self.assertEqual(articles[0].AgeTimeUnix, 863982)
Пример #7
0
 def test_ticket_create(self):
     t = Ticket(State='new',
                Priority='3 normal',
                Queue='Support',
                Title='Problem test',
                CustomerUser='******',
                Type='Divers')
     a = Article(Subject='UnitTest',
                 Body='bla',
                 Charset='UTF8',
                 MimeType='text/plain')
     t_id, t_number = self.c.ticket_create(t, a)
     self.assertIsInstance(t_id, int)
     self.assertIsInstance(t_number, int)
     self.assertTrue(len(str(t_number)) >= 12)
Пример #8
0
 def test_ticket_from_xml(self):
     xml = etree.fromstring(SAMPLE_TICKET)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')
Пример #9
0
 def test_ticket_from_xml(self):
     xml = etree.fromstring(SAMPLE_TICKET)
     t = Ticket.from_xml(xml)
     self.assertEqual(t.TicketID, 32)
     self.assertEqual(t.CustomerUserID, '*****@*****.**')
Пример #10
0
 def test_ticket(self):
     t = Ticket(TicketID=42, EscalationResponseTime='43')
     self.assertEqual(t.TicketID, 42)
     self.assertEqual(t.EscalationResponseTime, 43)