Mock external api call (xero)

27 views
Skip to first unread message

Karim

unread,
Sep 22, 2016, 8:52:21 AM9/22/16
to Django Users
Hello everyone, I would like to test my code that call the xero api server and to do that I want create mocked response to test different scenarios.

At the moment I want test just few endpoints, my Idea is to create a class as a container of the items needed to render.

The items are generated by a class that use a "stamp" of the returned json and add or modify the stamp using the given kwargs.

What you think about the example above? Maybe you have better idea?

e.g.

    response = MockedXeroResponse()

    invoice = fakeInvoice(**kwargs)  # kwargs add fields 
    another_invoice = fakeInvoice(**{'Amount':1000})

    response.add(invoice, another_invoice)  # 
    response.json  # return the json response as the XERO api with the two invoices.


​Thank you​

--
Karim N. Gorjux
Reply all
Reply to author
Forward
0 new messages