Signed-off-by: Patrick Uiterwijk puiterwijk@redhat.com
rebased onto 61c05f84713ca5564b732cdcf88b24501434972c
This needs to be flask.current_app now
flask.current_app
rebased onto 6058d5d5c01a9ff779abfaff85553746a770aca1
1 new commit added
IIRC, there are flake8 errors we need to address and I had to apply these changes to get the test suite to pass:
diff --git a/ tests/test_pagure_flask_form.py b/ tests/test_pagure_flask_form.py index 5778bd30..a45a7a99 100644 --- a/ tests/test_pagure_flask_form.py +++ b/ tests/test_pagure_flask_form.py @@ -19,7 +19,7 @@ import os import flask import flask_wtf -from mock import patch +from mock import patch, MagicMock sys.path.insert(0, os.path.join(os.path.dirname( os.path.abspath(__file__)), '..')) @@ -38,12 +38,14 @@ class PagureFlaskFormTests(tests.SimplePagureTest): def test_csrf_form_no_input(self): """ Test the CSRF validation if not CSRF is specified. """ with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.ConfirmationForm() self.assertFalse(form.validate_on_submit()) def test_csrf_form_w_invalid_input(self): """ Test the CSRF validation with an invalid CSRF specified. """ with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.ConfirmationForm() form.csrf_token.data = 'foobar' self.assertFalse(form.validate_on_submit()) @@ -51,6 +53,7 @@ class PagureFlaskFormTests(tests.SimplePagureTest): def test_csrf_form_w_input(self): """ Test the CSRF validation with a valid CSRF specified. """ with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.ConfirmationForm() form.csrf_token.data = form.csrf_token.current_token self.assertTrue(form.validate_on_submit()) @@ -58,6 +61,7 @@ class PagureFlaskFormTests(tests.SimplePagureTest): def test_csrf_form_w_expired_input(self): """ Test the CSRF validation with an expired CSRF specified. """ with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.ConfirmationForm() data = form.csrf_token.current_token @@ -90,6 +94,7 @@ class PagureFlaskFormTests(tests.SimplePagureTest): """ Test the CSRF validation with a CSRF not expiring. """ pagure.config.config['WTF_CSRF_TIME_LIMIT'] = None with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.ConfirmationForm() data = form.csrf_token.current_token @@ -106,6 +111,7 @@ class PagureFlaskFormTests(tests.SimplePagureTest): def test_add_user_form(self): """ Test the AddUserForm of pagure.forms """ with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.AddUserForm() form.csrf_token.data = form.csrf_token.current_token # No user or access given @@ -119,6 +125,7 @@ class PagureFlaskFormTests(tests.SimplePagureTest): def test_add_user_to_group_form(self): """ Test the AddUserToGroup form of pagure.forms """ with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.AddUserToGroupForm() form.csrf_token.data = form.csrf_token.current_token # No user given @@ -130,6 +137,7 @@ class PagureFlaskFormTests(tests.SimplePagureTest): def test_add_group_form(self): """ Test the AddGroupForm form of pagure.forms """ with self.app.application.test_request_context(method='POST'): + flask.g.session = MagicMock() form = pagure.forms.AddGroupForm() form.csrf_token.data = form.csrf_token.current_token # No group given
rebased onto 71124eb2addbebba986a576bf817b78052b9c06c
Pull-Request has been merged by pingou
Signed-off-by: Patrick Uiterwijk puiterwijk@redhat.com