summaryrefslogtreecommitdiff
path: root/astroid/brain/brain_responses.py
blob: 0fb0e4269be14bbe4c9691a266ac6f432fd9f52e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt

"""
Astroid hooks for responses.

It might need to be manually updated from the public methods of
:class:`responses.RequestsMock`.

See: https://github.com/getsentry/responses/blob/master/responses.py

"""
from astroid.brain.helpers import register_module_extender
from astroid.builder import parse
from astroid.manager import AstroidManager


def responses_funcs():
    return parse(
        """
        DELETE = "DELETE"
        GET = "GET"
        HEAD = "HEAD"
        OPTIONS = "OPTIONS"
        PATCH = "PATCH"
        POST = "POST"
        PUT = "PUT"
        response_callback = None

        def reset():
            return

        def add(
            method=None,  # method or ``Response``
            url=None,
            body="",
            adding_headers=None,
            *args,
            **kwargs
        ):
            return

        def add_passthru(prefix):
            return

        def remove(method_or_response=None, url=None):
            return

        def replace(method_or_response=None, url=None, body="", *args, **kwargs):
            return

        def add_callback(
            method, url, callback, match_querystring=False, content_type="text/plain"
        ):
            return

        calls = []

        def __enter__():
            return

        def __exit__(type, value, traceback):
            success = type is None
            return success

        def activate(func):
            return func

        def start():
            return

        def stop(allow_assert=True):
            return
        """
    )


register_module_extender(AstroidManager(), "responses", responses_funcs)