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_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_init(self): tic = Ticket(dct={'Title': 'foo'}) self.assertIsInstance(tic, Ticket) self.assertEqual(tic.__repr__(), '<Ticket>')