webcompat / webcompat.com

Source code for webcompat.com
https://webcompat.com
360 stars 191 forks source link

Update Flask to 2.1.1 #3687

Open ksy36 opened 2 years ago

ksy36 commented 2 years ago

There are failing tests in the recent builds: https://app.circleci.com/pipelines/github/webcompat/webcompat.com/1893/workflows/3241893d-f701-43bd-b512-94fe64743ad0/jobs/1894

  if request is None:
>           builder = EnvironBuilder(*args, **kwargs)
E           TypeError: __init__() got an unexpected keyword argument 'as_tuple'

env/lib/python3.9/site-packages/werkzeug/test.py:1081: TypeError

Looks like this is happening because in version 2.1.0, werkzeug has removed the as_tuple argument and this most recent version is installed as a dependency of Flask. Our current version of Flask installed from requirements.txt is 2.0.1 still passes it, therefore the error is thrown.

https://flask.palletsprojects.com/en/2.1.x/changes/#version-2-1-0 The test client’s as_tuple parameter is removed. Use response.request.environ instead.

ksy36 commented 2 years ago

I have actually removed the freezing of version of werkzeug in https://github.com/webcompat/webcompat.com/pull/3621, but maybe the best would be to bring it back to avoid similar issues in the future.

Also see Karl's https://github.com/webcompat/webcompat.com/pull/3621#discussion_r714410149 for more information

ksy36 commented 2 years ago

With the update I'm getting 1 failing test:

_______________________________________________________________________________________________ TestURLs.test_successful_post_new_issue __________________________________________________________________________________________________

self = <tests.unit.test_urls.TestURLs testMethod=test_successful_post_new_issue>, mock_proxy = <MagicMock name='report_issue' id='4515001488'>

    @patch('webcompat.views.report_issue')
    def test_successful_post_new_issue(self, mock_proxy):
        """Test that anonymous post succeeds on /issues/new."""
        webcompat.app.config['ANONYMOUS_REPORTING_ENABLED'] = True
        mock_proxy.return_value = POST_RESPONSE
        rv = self.app.post(
            '/issues/new',
            content_type='multipart/form-data',
            environ_base=headers,
            data=dict(
                browser='Firefox Mobile 45.0',
                description='testing 2971',
                os='macos',
                problem_category='yada',
                submit_type='github-proxy-report',
                url='http://testing.example.org',
                username='yeeha'))
        assert rv.status_code == 302
        print(rv.headers)
>       assert rv.headers['Location'] == 'http://localhost/issues/1544'
E       AssertionError: assert '/issues/1544' == 'http://localhost/issues/1544'
E         - http://localhost/issues/1544
E         + /issues/1544

tests/unit/test_urls.py:78: AssertionError

The test is failing because of this change https://github.com/pallets/werkzeug/issues/2352. Also, the corresponding tests are here https://github.com/pallets/flask/pull/4496/files

This is not affecting the app, just the tests as far as I can tell, but I'll test the reporting on staging just in case :)