Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_tickets(self):
""" Helper method for creating some tickets with the raw_subject set. """
with self.recorder.use_cassette("{}-create".format(self.generate_cassette_name()), serialize_with='prettyjson'):
tickets = list()
for i in range(5):
tickets.append(Ticket(subject=str(i), raw_subject=str(i), description="desc{}".format(i)))
job_status = self.zenpy_client.tickets.create(tickets)
self.wait_for_job_status(job_status)
return tickets, [t for t in self.zenpy_client.tickets()]
def check_slice_range(self, values, slice_range):
self.assertEqual(len(values), len(slice_range))
for i, n in enumerate(slice_range):
self.assertIsInstance(values[i], Ticket)
self.assertTrue(values[i].id == n,
msg="expected Ticket id: {}, found: {}, values: {}".format(n, values[i], values))
def populate_cache(self, num_objects):
for i in range(num_objects):
self.cache[i] = Ticket(id=i)
def generate_tickets(self, num_tickets):
tickets = [Ticket(subject=str(i), description=str(i)) for i in range(num_tickets)]
job_status = self.zenpy_client.tickets.create(tickets)
self.wait_for_job_status(job_status)
def verify(self, ticket_count):
returned_tickets = [t for t in self.zenpy_client.tickets()]
self.assertEqual(len(returned_tickets), ticket_count)
for ticket in returned_tickets:
self.assertIsInstance(ticket, Ticket)
self.assertInCache(ticket)
def setUp(self):
super(TestTicketAPIMethods, self).setUp()
cassette_name = "{}-create-test-ticket".format(self.generate_cassette_name())
with self.recorder.use_cassette(cassette_name=cassette_name, serialize_with='prettyjson'):
self.subject = "subject"
self.comment = Comment(body="I am comment")
ticket_audit = self.zenpy_client.tickets.create(Ticket(subject=self.subject, comment=self.comment))
self.test_ticket = ticket_audit.ticket
zendesk_api.CustomField(id=30153569, value=last_login),
zendesk_api.CustomField(id=30295025, value=num_sounds),
zendesk_api.CustomField(id=30295045, value=num_posts),
zendesk_api.CustomField(id=30153729, value=num_comments),
]
user_url = "https://%s%s" % (
Site.objects.get_current().domain,
reverse('account', args=[user.username])
)
message += "\n\n-- \n%s" % user_url
requester.name = user.username
return zendesk_api.Ticket(
requester=requester,
subject=subject,
description=message,
custom_fields=custom_fields
)
if hasattr(o, 'to_dict'):
return o.to_dict()
elif isinstance(o, datetime):
return o.date().isoformat()
elif isinstance(o, date):
return o.isoformat()
class ClassManager(object):
"""
ClassManager provides methods for converting JSON objects
to the correct Python ones.
"""
class_mapping = {
'ticket': Ticket,
'user': User,
'organization': Organization,
'group': Group,
'brand': Brand,
'topic': Topic,
'comment': Comment,
'attachment': Attachment,
'thumbnail': Thumbnail,
'metadata': Metadata,
'system': System,
'create': CreateEvent,
'change': ChangeEvent,
'notification': NotificationEvent,
'voicecomment': VoiceCommentEvent,
'commentprivacychange': CommentPrivacyChangeEvent,
'satisfactionrating': SatisfactionRatingEvent,