Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky test #2385

Open
mbertrand opened this issue Apr 6, 2022 · 0 comments
Open

Flaky test #2385

mbertrand opened this issue Apr 6, 2022 · 0 comments
Labels
Bug Something isn't working

Comments

@mbertrand
Copy link
Member

This failed once when deploying a new RC release.

____________________ test_get_valid_edx_api_auth_unexpired _____________________

    @responses.activate
    @freeze_time("2019-03-24 11:50:36")
    def test_get_valid_edx_api_auth_unexpired():
        """Tests get_valid_edx_api_auth returns the current record if it is valid long enough"""
        auth = OpenEdxApiAuthFactory.create()
    
>       updated_auth = get_valid_edx_api_auth(auth.user)

courseware/api_test.py:251: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
courseware/api.py:358: in get_valid_edx_api_auth
    return _refresh_edx_api_auth(auth)
courseware/api.py:381: in _refresh_edx_api_auth
    client_secret=settings.OPENEDX_API_CLIENT_SECRET,
courseware/api.py:250: in _create_tokens_and_update_auth
    resp = requests.post(edx_url(OPENEDX_OAUTH2_ACCESS_TOKEN_PATH), data=params)
/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/requests/api.py:117: in post
    return request('post', url, data=data, json=json, **kwargs)
/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/requests/api.py:61: in request
    return session.request(method=method, url=url, **kwargs)
/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/requests/sessions.py:529: in request
    resp = self.send(prep, **send_kwargs)
/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/requests/sessions.py:645: in send
    r = adapter.send(request, **kwargs)
/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/responses/__init__.py:841: in unbound_on_send
    return self._on_request(adapter, request, *a, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <responses.RequestsMock object at 0x7fca64b38c90>
adapter = <requests.adapters.HTTPAdapter object at 0x7fca4da0b1d0>
request = <PreparedRequest [POST]>
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': None, ...}
match = None, match_failed_reasons = [], resp_callback = None
error_msg = "Connection refused by Responses - the call doesn't match any registered mock.\n\nRequest: \n- POST http://localhost:[180](https://github.com/mitodl/mitxpro/runs/5856049181?check_suite_focus=true#step:14:180)00/oauth2/access_token\n\nAvailable matches:\n"

    def _on_request(self, adapter, request, **kwargs):
        # add attributes params and req_kwargs to 'request' object for further match comparison
        # original request object does not have these attributes
        request.params = self._parse_request_params(request.path_url)
        request.req_kwargs = kwargs
    
        match, match_failed_reasons = self._find_match(request)
        resp_callback = self.response_callback
    
        if match is None:
            if any(
                [
                    p.match(request.url)
                    if isinstance(p, Pattern)
                    else request.url.startswith(p)
                    for p in self.passthru_prefixes
                ]
            ):
                logger.info("request.allowed-passthru", extra={"url": request.url})
                return _real_send(adapter, request, **kwargs)
    
            error_msg = (
                "Connection refused by Responses - the call doesn't "
                "match any registered mock.\n\n"
                "Request: \n"
                f"- {request.method} {request.url}\n\n"
                "Available matches:\n"
            )
            for i, m in enumerate(self.registered()):
                error_msg += "- {} {} {}\n".format(
                    m.method, m.url, match_failed_reasons[i]
                )
    
            if self.passthru_prefixes:
                error_msg += "Passthru prefixes:\n"
                for p in self.passthru_prefixes:
                    error_msg += "- {}\n".format(p)
    
            response = ConnectionError(error_msg)
            response.request = request
    
            self._calls.add(request, response)
>           raise response
E           requests.exceptions.ConnectionError: Connection refused by Responses - the call doesn't match any registered mock.
E           
E           Request: 
E           - POST http://localhost:18000/oauth2/access_token
E           
E           Available matches:

/opt/hostedtoolcache/Python/3.7.5/x64/lib/python3.7/site-packages/responses/__init__.py:815: ConnectionError
@mbertrand mbertrand added the Bug Something isn't working label Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant