Skip to main content

Library for unittesting json REST apis built with pymacaron

Project description

pymacaron-unit

Python library for unittesting json REST apis built with pymacaron, including support for JWT authentication, Error formats used by pymacaron and compatible with 'pymtest', the testing tool used in pymacaron microservices.

Synopsis

    from pymacaron_unit.testcase import PyMacaronTestCase

    class Tests(PyMacaronTestCase):

        def setUp(self):
            super.setUp()
            self.host = 'api.fixer.io'
            self.port = 80

        def test_make_some_calls(self):

            # Test that GET returns a json structure
            j = self.assertGetReturnJson(
                "v1/hello",
            )

            # Same, with setting the Authorization http header to a JWT token
            j = self.assertGetReturnJson(
                "v1/hello",
                auth="Bearer %s" % self.token
            )

            # Do a POST
            j = self.assertPostReturnJson(
                "v1/hello",
                {
                    'foo': 'bar',
                }
            )

See pymacaron_unit/testcase.py for a complete list of test methods.

Examples

See test/test_unit.py :-)

Author

Erwan Lemonnier
github.com/pymacaron
github.com/erwan-lemonnier
www.linkedin.com/in/erwan-lemonnier/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pymacaron-unit, version 1.0.17
Filename, size File type Python version Upload date Hashes
Filename, size pymacaron-unit-1.0.17.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page