aboutsummaryrefslogtreecommitdiff
path: root/test/requests/test-registration.py
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-02-16 14:22:17 +0300
committerPjotr Prins2018-03-26 09:29:29 +0000
commitc5b1028a15c771508b2b88994869912330c1148e (patch)
tree2e4f9f267e91ca0e7105a014c4c103c930a49098 /test/requests/test-registration.py
parent375935b23778148eba40ebce4a4f4def823aa3f0 (diff)
downloadgenenetwork2-c5b1028a15c771508b2b88994869912330c1148e.tar.gz
Add registration test
* Add integration test to check the registration process.
Diffstat (limited to 'test/requests/test-registration.py')
-rw-r--r--test/requests/test-registration.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/requests/test-registration.py b/test/requests/test-registration.py
new file mode 100644
index 00000000..bcb1642f
--- /dev/null
+++ b/test/requests/test-registration.py
@@ -0,0 +1,59 @@
+import sys
+import unittest
+import requests
+import logging
+from elasticsearch import Elasticsearch, TransportError
+#from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT
+
+GN2_SERVER = None
+ES_SERVER = None
+
+class TestRegistration(unittest.TestCase):
+
+
+ def setUp(self):
+ self.url = GN2_SERVER+"/n/register"
+ self.es = Elasticsearch([ES_SERVER])
+ self.es_cleanup = []
+
+ es_logger = logging.getLogger("elasticsearch")
+ es_logger.addHandler(
+ logging.FileHandler("/tmp/es_TestRegistrationInfo.log"))
+ es_trace_logger = logging.getLogger("elasticsearch.trace")
+ es_trace_logger.addHandler(
+ logging.FileHandler("/tmp/es_TestRegistrationTrace.log"))
+
+ def tearDown(self):
+ for item in self.es_cleanup:
+ self.es.delete(index="users", doc_type="local", id=item["_id"])
+
+ def testRegistrationPage(self):
+ if self.es.ping():
+ data = {
+ "email_address": "test@user.com",
+ "full_name": "Test User",
+ "organization": "Test Organisation",
+ "password": "test_password",
+ "password_confirm": "test_password"
+ }
+ requests.post(self.url, data)
+ response = self.es.search(
+ index="users"
+ , doc_type="local"
+ , body={
+ "query": {"match": {"email_address": "test@user.com"}}})
+ self.assertEqual(len(response["hits"]["hits"]), 1)
+ self.es_cleanup.append(response["hits"]["hits"][0])
+ else:
+ self.skipTest("The elasticsearch server is down")
+
+def main():
+ suite = unittest.TestSuite()
+ suite.addTest(TestRegistration("testRegistrationPage"))
+ runner = unittest.TextTestRunner()
+ runner.run(suite)
+
+if __name__ == "__main__":
+ GN2_SERVER = sys.argv[1]
+ ES_SERVER = sys.argv[2]
+ main()