summaryrefslogtreecommitdiff
path: root/inventory/tests.py
diff options
context:
space:
mode:
authorshivam kohli <kohlishivam5522@gmail.com>2018-07-23 04:29:14 +0530
committershivam kohli <kohlishivam5522@gmail.com>2018-07-23 04:29:14 +0530
commitc60f075634178d2212364c842552c256f22dae92 (patch)
tree3bd06f4bf0b6fe497902229fb9acf480e6520c9a /inventory/tests.py
parent94be0d7216ec3c5f253b895681b11e7b0678211a (diff)
downloadcodeless-c60f075634178d2212364c842552c256f22dae92.tar.gz
codeless-c60f075634178d2212364c842552c256f22dae92.tar.bz2
codeless-c60f075634178d2212364c842552c256f22dae92.zip
testcase added and improved user interface
Diffstat (limited to 'inventory/tests.py')
-rw-r--r--inventory/tests.py68
1 files changed, 67 insertions, 1 deletions
diff --git a/inventory/tests.py b/inventory/tests.py
index 7ce503c..276cfdc 100644
--- a/inventory/tests.py
+++ b/inventory/tests.py
@@ -1,3 +1,69 @@
from django.test import TestCase
+from django.test import LiveServerTestCase
+from selenium import webdriver
+from selenium.webdriver.common.keys import Keys
+import time
-# Create your tests here.
+
+class SignUpTestCase(LiveServerTestCase):
+
+ def setUp(self):
+ self.selenium = webdriver.Firefox(executable_path=r'/geckodriver')
+ super(SignUpTestCase, self).setUp()
+
+ def tearDown(self):
+ self.selenium.quit()
+ super(SignUpTestCase, self).tearDown()
+
+ def test_register(self):
+ selenium = self.selenium
+ #Opening the link we want to test
+ selenium.get('http://localhost:8000/signup/')
+ username = selenium.find_element_by_id('id_username')
+ first_name = selenium.find_element_by_id('id_first_name')
+ last_name = selenium.find_element_by_id('id_last_name')
+ email = selenium.find_element_by_id('id_email')
+ password1 = selenium.find_element_by_id('id_password1')
+ password2 = selenium.find_element_by_id('id_password2')
+ submit = selenium.find_element_by_name('add_product')
+ #Fill the form with data
+ first_name.send_keys('eeeeee')
+ last_name.send_keys('Unaryk')
+ username.send_keys('test1')
+ email.send_keys('yusuf@qawba.com')
+ password1.send_keys('123456')
+ password2.send_keys('123456')
+ #submitting the form
+ submit.send_keys(Keys.RETURN)
+ #check the returned result
+ time.sleep(1)
+ # print(selenium.page_source)
+ assert 'DIGITAL INVENTORY' in selenium.page_source
+
+
+class LoginTestCase(LiveServerTestCase):
+
+ def setUp(self):
+ self.selenium = webdriver.Firefox(executable_path=r'/geckodriver')
+ super(LoginTestCase, self).setUp()
+
+ def tearDown(self):
+ self.selenium.quit()
+ super(LoginTestCase, self).tearDown()
+
+ def test_register(self):
+ selenium = self.selenium
+ #Opening the link we want to test
+ selenium.get('http://localhost:8000/accounts/login/')
+ username = selenium.find_element_by_id('id_username')
+ password = selenium.find_element_by_id('id_password')
+ submit = selenium.find_element_by_name('add_product')
+ #Fill the form with data
+ username.send_keys('admin')
+ password.send_keys('admin')
+ #submitting the form
+ submit.send_keys(Keys.RETURN)
+ #check the returned result
+ time.sleep(1)
+ # print(selenium.page_source)
+ assert 'DIGITAL INVENTORY' in selenium.page_source