diff options
author | Pjotr Prins | 2018-03-19 10:52:28 +0100 |
---|---|---|
committer | GitHub | 2018-03-19 10:52:28 +0100 |
commit | b359cb0712e9ef923d35524f310d841581d48f30 (patch) | |
tree | 3c4cafc0bc0b481490674c807f279b4371130d0c /test/requests/test_login_local.py | |
parent | 2602be69f2869de376d1b9ced6131d880e9476c2 (diff) | |
parent | 5ccf077f53c6546bb9258c7116b4b1cf8903375f (diff) | |
download | genenetwork2-b359cb0712e9ef923d35524f310d841581d48f30.tar.gz |
Merge pull request #5 from fredmanglis/testing
Testing
Diffstat (limited to 'test/requests/test_login_local.py')
-rw-r--r-- | test/requests/test_login_local.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/requests/test_login_local.py b/test/requests/test_login_local.py new file mode 100644 index 00000000..808649ca --- /dev/null +++ b/test/requests/test_login_local.py @@ -0,0 +1,60 @@ +import requests +from wqflask import user_manager +from parameterized import parameterized +from parametrized_test import ParametrizedTest + +login_link_text = '<a id="login_in" href="/n/login">Sign in</a>' +logout_link_text = '<a id="login_out" title="Signed in as ." href="/n/logout">Sign out</a>' + +class TestLoginLocal(ParametrizedTest): + + def setUp(self): + super(TestLoginLocal, self).setUp() + self.login_url = self.gn2_url +"/n/login" + data = { + "es_connection": self.es, + "email_address": "test@user.com", + "full_name": "Test User", + "organization": "Test Organisation", + "password": "test_password", + "password_confirm": "test_password" + } + user_manager.basic_info = lambda : { "basic_info": "basic" } + user_manager.RegisterUser(data) + + + @parameterized.expand([ + ( + { + "email_address": "non@existent.email", + "password": "doesitmatter?" + }, login_link_text, "Login should have failed with the wrong user details."), + ( + { + "email_address": "test@user.com", + "password": "test_password" + }, logout_link_text, "Login should have been successful with correct user details and neither import_collections nor remember_me set"), + ( + { + "email_address": "test@user.com", + "password": "test_password", + "import_collections": "y" + }, logout_link_text, "Login should have been successful with correct user details and only import_collections set"), + ( + { + "email_address": "test@user.com", + "password": "test_password", + "remember_me": "y" + }, logout_link_text, "Login should have been successful with correct user details and only remember_me set"), + ( + { + "email_address": "test@user.com", + "password": "test_password", + "remember_me": "y", + "import_collections": "y" + }, logout_link_text, "Login should have been successful with correct user details, and both remember_me, and import_collections set") + ]) + def testLogin(self, data, expected, message): + result = requests.post(self.login_url, data=data) + index = result.content.find(expected) + self.assertTrue(index >= 0, message) |