def test_init_parse_from_dct(self): tic_dct = { 'TypeID': '1', 'Title': 'Baesic Ticket', 'Article': [{ 'Age': 82383, 'AgeTimeUnix': 82383, 'ArticleID': '30', 'ArticleType': 'webrequest', 'ArticleTypeID': '8', 'Attachment': [{ 'Content': 'mFyC', 'ContentAlternative': '', 'ContentID': '', 'ContentType': 'text/plain', 'Disposition': 'attachment', 'Filename': 'foo.txt', 'Filesize': '3 Bytes', 'FilesizeRaw': '3' }], 'Body': 'Hallo Bjørn,\n[kt]\n\n -- The End', 'Cc': '', 'CustomerID': None, 'CustomerUserID': None, 'EscalationResponseTime': '0', 'EscalationSolutionTime': '0' }], 'DynamicField': [{ 'Name': 'ProcessManagementActivityID', 'Value': None }, { 'Name': 'ProcessManagementProcessID', 'Value': None }, { 'Name': 'firstname', 'Value': 'Jane' }, { 'Name': 'lastname', 'Value': 'Doe' }], } tic = Ticket(tic_dct) self.assertIsInstance(tic, Ticket) self.assertEqual(tic.__repr__(), '<Ticket>') self.assertEqual(tic.articles[0].__repr__(), "<ArticleID: 30 (1 Attachment)>")
def test_dynamic_field_get_none(self): tic_dct = { 'TypeID': '1', 'Title': 'Baesic Ticket', 'Article': [{ 'Age': 82383, 'AgeTimeUnix': 82383, 'ArticleID': '30', 'ArticleType': 'webrequest', 'ArticleTypeID': '8', 'Attachment': [{ 'Content': 'mFyC', 'ContentAlternative': '', 'ContentID': '', 'ContentType': 'text/plain', 'Disposition': 'attachment', 'Filename': 'foo.txt', 'Filesize': '3 Bytes', 'FilesizeRaw': '3' }], 'Body': 'Hallo Bjørn,\n[kt]\n\n -- The End', 'Cc': '', 'CustomerID': None, 'CustomerUserID': None, 'EscalationResponseTime': '0', 'EscalationSolutionTime': '0' }], 'DynamicField': [{ 'Name': 'ProcessManagementActivityID', 'Value': None }, { 'Name': 'ProcessManagementProcessID', 'Value': None }, { 'Name': 'firstname', 'Value': 'Jane' }, { 'Name': 'lastname', 'Value': 'Doe' }], } tic = Ticket(tic_dct) self.assertIsInstance(tic, Ticket) self.assertIsNone(tic.dynamic_field_get("rgiosregoisrengi"))
def test_init_nested_dct(self): tic = Ticket( dct={ 'Title': 'foo', 'SomeField': 'SomeValue', 'SomeDict': { 'NestedDictField1': "Value1", 'NestedDictField2': "Value2" } }) self.assertIsInstance(tic, Ticket) self.assertEqual(tic.__repr__(), '<Ticket>')
def test_create_basic_title_queue_state_prio_customer_four(self): tic = Ticket.create_basic(Title='foobar', Queue='raw', StateID='4', Priority='average', CustomerUser='******') self.assertIsInstance(tic, Ticket) self.assertEqual(tic.__repr__(), '<Ticket>')
def test_create_basic_title_queue_state_prio_customer_two(self): tic = Ticket.create_basic(Title='foobar', Queue='raw', TypeID='2', State='open', PriorityID='5', CustomerUser='******') self.assertIsInstance(tic, Ticket) self.assertEqual(tic.__repr__(), '<Ticket>')
def test_dummy(self): tic = Ticket._dummy() self.assertDictEqual( tic.to_dct(), { 'Ticket': { 'Queue': u'Raw', 'State': u'open', 'Priority': u'3 normal', 'CustomerUser': '******', 'Title': 'Bäsic Ticket' } })
def test_pending_text(self): tic = Ticket.create_basic(Title='foobar', QueueID='1', State='open', PriorityID='5', CustomerUser='******') self.assertDictEqual( tic.datetime_to_pending_time_text(datetime(1, 2, 3, 4, 5)), { 'Day': 3, 'Hour': 4, 'Minute': 5, 'Month': 2, 'Year': 1 })
def test_create_basic_title_queue_state_prio_customer_to_dct(self): tic = Ticket.create_basic(Title='foobar', QueueID='1', State='open', PriorityID='5', CustomerUser='******') self.assertIsInstance(tic, Ticket) self.assertDictEqual( tic.to_dct(), { 'Ticket': { 'Title': 'foobar', 'QueueID': '1', 'State': 'open', 'PriorityID': '5', 'CustomerUser': '******' } })
def test_ticket_to_dct_no_articles_dynamic_fields(self): tic = Ticket.create_basic(Title='foobar', QueueID='1', State='open', PriorityID='5', CustomerUser='******') self.assertIsInstance(tic, Ticket) delattr(tic, 'articles') delattr(tic, 'dynamic_fields') self.assertDictEqual( tic.to_dct(), { 'Ticket': { 'Title': 'foobar', 'QueueID': '1', 'State': 'open', 'PriorityID': '5', 'CustomerUser': '******' } })
def test_to_dct_full(self): self.maxDiff = None tic_dct = { 'TypeID': '1', 'Title': 'Baesic Ticket', 'Article': [{ 'Age': 82383, 'AgeTimeUnix': 82383, 'ArticleID': '30', 'ArticleType': 'webrequest', 'ArticleTypeID': '8', 'Attachment': [{ 'Content': 'mFyC', 'ContentAlternative': '', 'ContentID': '', 'ContentType': 'text/plain', 'Disposition': 'attachment', 'Filename': 'foo.txt', 'Filesize': '3 Bytes', 'FilesizeRaw': '3' }], 'Body': 'Hallo Bjørn,\n[kt]\n\n -- The End', 'Cc': '', 'CustomerID': None, 'CustomerUserID': None, 'EscalationResponseTime': '0', 'EscalationSolutionTime': '0' }], 'DynamicField': [{ 'Name': 'ProcessManagementActivityID', 'Value': None }, { 'Name': 'ProcessManagementProcessID', 'Value': None }, { 'Name': 'firstname', 'Value': 'Jane' }, { 'Name': 'lastname', 'Value': 'Doe' }], } tic = Ticket(tic_dct) self.assertDictEqual( tic.to_dct(), { 'Ticket': { 'TypeID': '1', 'Title': 'Baesic Ticket', 'Article': [{ 'Age': 82383, 'AgeTimeUnix': 82383, 'ArticleID': '30', 'ArticleType': 'webrequest', 'ArticleTypeID': '8', 'Attachment': [{ 'Content': 'mFyC', 'ContentAlternative': '', 'ContentID': '', 'ContentType': 'text/plain', 'Disposition': 'attachment', 'Filename': 'foo.txt', 'Filesize': '3 Bytes', 'FilesizeRaw': '3' }], 'Body': 'Hallo Bjørn,\n[kt]\n\n -- The End', 'Cc': '', 'CustomerID': None, 'CustomerUserID': None, 'EscalationResponseTime': '0', 'EscalationSolutionTime': '0' }], 'DynamicField': [{ 'Name': 'ProcessManagementActivityID', 'Value': None }, { 'Name': 'ProcessManagementProcessID', 'Value': None }, { 'Name': 'firstname', 'Value': 'Jane' }, { 'Name': 'lastname', 'Value': 'Doe' }], } })
def test_init(self): tic = Ticket(dct={'Title': 'foo'}) self.assertIsInstance(tic, Ticket) self.assertEqual(tic.__repr__(), '<Ticket>')