Giter Club home page Giter Club logo

Comments (2)

wojcikstefan avatar wojcikstefan commented on July 29, 2024

We've been successfully testing our requests to Plivo and mocking Plivo responses with https://github.com/patrys/httmock. A sample code looks like this:

def test_delete_phone_number(self):
    requests_list = []  # track all the requests made to plivo

    @urlmatch(netloc='api\.plivo\.com')
    def response_content(url, request):
        requests_list.append((request.method, url.geturl()))
        return { 'status_code': 204, 'content': '' }

    with HTTMock(response_content):
        resp = self.delete('/api/v1/phone_number/{}/'.format(pn.pk), api_key=test_api_key)
        response_success(resp)

    # Assert that we only made a single DELETE request to Plivo
    self.assertEqual(requests_list, [
        ('DELETE', 'https://api.plivo.com/v1/Account/TEST_PLIVO_AUTH_ID/Number/16503334444/')
    ])

You can also have a more sophisticated logic of what to respond with depending on the request data/url and you can put asserts inside of response_content. Hope this is helpful.

from plivo-python.

kumaresan-plivo avatar kumaresan-plivo commented on July 29, 2024

Thanks @wojcikstefan, sounds like a good fit.

from plivo-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.