From 2b440eddc4643f1401db684ec273e6241d609db8 Mon Sep 17 00:00:00 2001 From: Vivek Anand Date: Feb 15 2017 10:30:34 +0000 Subject: Unit test: AddUserForm and AddUserToGroupForm Signed-off-by: Vivek Anand --- diff --git a/tests/test_pagure_flask_form.py b/tests/test_pagure_flask_form.py index 916c3f8..5ec6e04 100644 --- a/tests/test_pagure_flask_form.py +++ b/tests/test_pagure_flask_form.py @@ -105,6 +105,30 @@ class PagureFlaskFormTests(tests.Modeltests): form.csrf_token.data = '##%s' % hmac_csrf self.assertTrue(form.validate_on_submit()) + def test_add_user_form(self): + """ Test the AddUserForm of pagure.forms """ + with pagure.APP.test_request_context(method='POST'): + form = pagure.forms.AddUserForm() + form.csrf_token.data = form.csrf_token.current_token + # No user or access given + self.assertFalse(form.validate_on_submit()) + # No access given + form.user.data = 'foo' + self.assertFalse(form.validate_on_submit()) + form.access.data = 'admin' + self.assertTrue(form.validate_on_submit()) + + def test_add_user_to_group_form(self): + """ Test the AddUserToGroup form of pagure.forms """ + with pagure.APP.test_request_context(method='POST'): + form = pagure.forms.AddUserToGroupForm() + form.csrf_token.data = form.csrf_token.current_token + # No user given + self.assertFalse(form.validate_on_submit()) + form.user.data = 'foo' + # Everything given + self.assertTrue(form.validate_on_submit()) + if __name__ == '__main__': SUITE = unittest.TestLoader().loadTestsFromTestCase(