How to use the amadeus.ParserError function in amadeus

To help you get started, we’ve selected a few amadeus 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 amadeus4dev / amadeus-python / specs / mixins / parser_spec.py View on Github external
expect(lambda: self.response._detect_error(self.client)).to(
                raise_error(NotFoundError)
            )

        with it('should raise a generic client error for any other 4XX error'):
            self.response.status_code = 400
            self.response.parsed = False
            expect(lambda: self.response._detect_error(self.client)).to(
                raise_error(ClientError)
            )

        with it('should raise a parser error if the result was not parsed'):
            self.response.status_code = 200
            self.response.parsed = False
            expect(lambda: self.response._detect_error(self.client)).to(
                raise_error(ParserError)
            )
github amadeus4dev / amadeus-python / specs / mixins / parser_spec.py View on Github external
response._parse(self.client)
                expect(response.body).to(equal('Hello World'))
                expect(response.result).to(be(None))
                expect(response.data).to(be(None))

            with it('should raise a ParseError if it could not be parsed'):
                with Stub() as http_response:
                    http_response.status_code = '200'
                    http_response.getheaders().returns(
                        [('Content-Type', 'application/json')]
                    )
                    http_response.read().returns('{')

                response = Response(http_response, self.request)
                expect(lambda: response._parse(self.client)).to(
                    raise_error(ParserError)
                )

    with context('Response._detect_error'):
        with before.all:
            http_response = Stub()
            request = Stub(Request)
            self.client = Stub(Client)
            self.client.log_level = 'silent'
            self.response = Response(http_response, request)

        with it('should raise a network error if no status code was found'):
            self.response.status_code = None
            self.response.parsed = False
            expect(lambda: self.response._detect_error(self.client)).to(
                raise_error(NetworkError)
            )