From be8735f62aebfd1bca21d2255a0e7aad4dc599ac Mon Sep 17 00:00:00 2001 From: skrzepto Date: Jul 21 2016 21:03:21 +0000 Subject: fixed logout test and added adding widget test --- diff --git a/hubs/tests/test_fedora_hubs_flask_api.py b/hubs/tests/test_fedora_hubs_flask_api.py index d099987..49ab3d7 100644 --- a/hubs/tests/test_fedora_hubs_flask_api.py +++ b/hubs/tests/test_fedora_hubs_flask_api.py @@ -34,17 +34,12 @@ class HubsAPITest(hubs.tests.APPTest): '/login">login' in result.data) def test_hub_logged_out(self): - with app.test_request_context('/ralph'): - import flask - flask.g.oidc_id_token = None - # need to manually call the @app.before_request - # since unittest don't call it - hubs.app.check_auth() + with tests.auth_set(app, None): # check_auth doesn't load in unittest result = self.app.get('/ralph', follow_redirects=True) - # assert the status code of the response self.assertEqual(result.status_code, 200) - str_expected = 'Not logged in. Click to ' \ - 'login' + str_expected = '
Ralph
' + self.assertTrue(str_expected in result.data) + str_expected = 'Not logged in.' self.assertTrue(str_expected in result.data) def test_groups_logged_out(self): @@ -325,6 +320,19 @@ class HubsAPITest(hubs.tests.APPTest): result = self.app.get(url) self.assertEqual(result.data, '1') + def test_hub_add_widget_valid_side(self): + user = tests.FakeAuthorization('ralph') + with tests.auth_set(app, user): + url = '/ralph/add/about?position=right' + result = self.app.get(url) + self.assertTrue('Adding widget "about"to hub: ralph' in result.data) + + def test_hub_add_widget_invalid_side(self): + user = tests.FakeAuthorization('ralph') + with tests.auth_set(app, user): + url = '/ralph/add/about?position=invalid' + result = self.app.get(url) + self.assertEqual(result.status_code, 400) if __name__ == '__main__': unittest.main()