diff options
author | Muriithi Frederick Muriuki | 2018-02-19 12:50:30 +0300 |
---|---|---|
committer | Pjotr Prins | 2018-03-26 09:29:29 +0000 |
commit | c84bd98971aa5839cb6aa999889a92071890f579 (patch) | |
tree | 4ad935324a9aef0808d3486bb02dc5d789f1320f /test/requests | |
parent | f74b1615567d5cbf2cb00572cc14450ffd4b0c1c (diff) | |
download | genenetwork2-c84bd98971aa5839cb6aa999889a92071890f579.tar.gz |
Add test for local login
* Add an integration test to test that the login process for users
registered locally to genenetwork2 works as expected.
Diffstat (limited to 'test/requests')
-rw-r--r-- | test/requests/test_login_local.py | 56 |
1 files changed, 56 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..bced1ee9 --- /dev/null +++ b/test/requests/test_login_local.py @@ -0,0 +1,56 @@ +import requests +from wqflask import user_manager +from parametrized_test import ParametrizedTest + +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) + + def testLoginNonRegisteredUser(self): + data = { + "email_address": "non@existent.email", + "password": "doesitmatter?" + } + result = requests.post(self.login_url, data=data) + self.assertEqual(result.url, self.login_url, "") + + def testLoginWithRegisteredUserBothRememberMeAndImportCollectionsFalse(self): + data = { + "email_address": "test@user.com", + "password": "test_password" + } + result = requests.post(self.login_url, data=data) + print("THE COOKIES? ", result.cookies) + self.assertEqual( + result.url + , self.gn2_url+"/?import_collections=false" + , "Login should have been successful") + + + +def main(gn2, es): + import unittest + suite = unittest.TestSuite() + suite.addTest(TestLoginLocal(methodName="testLoginNonRegisteredUser", gn2_url=gn2, es_url=es)) + suite.addTest(TestLoginLocal(methodName="testLoginWithRegisteredUserBothRememberMeAndImportCollectionsFalse", gn2_url=gn2, es_url=es)) + runner = unittest.TextTestRunner() + runner.run(suite) + +if __name__ == "__main__": + import sys + if len(sys.argv) < 3: + raise Exception("Required arguments missing") + else: + main(sys.argv[1], sys.argv[2]) |