How to use zenpy - 10 common examples

To help you get started, we’ve selected a few zenpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facetoe / zenpy / tests / test_api / fixtures / __init__.py View on Github external
def recursively_call_properties(self, zenpy_object):
        """ Recursively test that a Zenpy object's properties, and each linked property can be called without error. """
        for attr_name in dir(zenpy_object):
            if isinstance(getattr(type(zenpy_object), attr_name, None), property):
                prop_val = getattr(zenpy_object, attr_name)
                if prop_val and issubclass(prop_val.__class__, BaseObject):
                    self.recursively_call_properties(prop_val)
                elif issubclass(prop_val.__class__, BaseResultGenerator):
                    for obj in prop_val:
                        self.recursively_call_properties(obj)
github facetoe / zenpy / tests / test_api / test_properties.py View on Github external
def iter_classes(mod):
    for cls in vars(mod).values():
        if isinstance(cls, type) and cls not in (BaseObject, ProxyDict, ProxyList):
            yield cls
github facetoe / zenpy / tests / test_ticket_endpoint.py View on Github external
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()]
github facetoe / zenpy / tests / test_api / test_generator.py View on Github external
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))
github facetoe / zenpy / tests / test_cache / test_cache.py View on Github external
def populate_cache(self, num_objects):
        for i in range(num_objects):
            self.cache[i] = Ticket(id=i)
github facetoe / zenpy / tests / test_ticket_endpoint.py View on Github external
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)
github facetoe / zenpy / tests / test_ticket_endpoint.py View on Github external
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)
github facetoe / zenpy / tests / test_ticket_endpoint.py View on Github external
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
github facetoe / zenpy / tests / test_cache / test_cache.py View on Github external
def test_cache_object(self):
        cache_key = 1
        ticket = self.cache_item(id=cache_key)
        self.assertIs(self.cache.get(get_object_type(ticket), cache_key), ticket)
github facetoe / zenpy / tests / test_api / test_proxy.py View on Github external
def test_list_access_wrapped(self):
        self.proxy_list.append([])
        item = self.proxy_list[-1]
        self.assertIsInstance(item, ProxyList)