示例#1
0
    def test_error_response_raises_request_exception(self):
        with requests_mock.mock() as request:
            request.register_uri('GET',
                                 'http://localhost:15672/api/definitions',
                                 status_code=400,
                                 text='{"error": "test error"}')

            args = rmq_definitions.parse_cli_arguments([])
            with self.assertRaises(rmq_definitions.RequestException):
                rmq_definitions.get_definitions(args)
示例#2
0
    def test_method_returns_dict(self):
        expectation = {'fake': 'data', 'value': str(uuid.uuid4())}
        with requests_mock.mock() as request:
            request.register_uri('GET',
                                 'http://localhost:15672/api/definitions',
                                 status_code=200,
                                 text=json.dumps(expectation))

            args = rmq_definitions.parse_cli_arguments([])
            response = rmq_definitions.get_definitions(args)
            self.assertDictEqual(response, expectation)
示例#3
0
 def test_connection_error_raises_request_exception(self):
     args = rmq_definitions.parse_cli_arguments(
         ['--url', 'http://255.255.255.255:15672'])
     with self.assertRaises(rmq_definitions.RequestException):
         rmq_definitions.get_definitions(args)