Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2017-07-26 22:17:47 +0300
committernachoparker <nacho@ownyourbits.com>2017-08-11 00:17:56 +0300
commitc9a6c57e2f261b0676d285f6ce4947d5ccd6bb2b (patch)
treeb8e331163e86b9a7ceb56b18706330c042dd0f92
parent93a2b0ae058eced6fbb93af63c3b7fd62cc52466 (diff)
tests: review style and fixes
-rwxr-xr-xtests/tests.py86
1 files changed, 46 insertions, 40 deletions
diff --git a/tests/tests.py b/tests/tests.py
index 47207ecf..ebf10688 100755
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -1,74 +1,77 @@
#!/usr/bin/env python3
-# Automatic testing for NextCloudPi
-#
-# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
-# GPL licensed (see end of file) * Use at your own risk!
-#
-# ./tests.py <IP>
-#
-# More at https://ownyourbits.com
-#
+"""
+Automatic testing for NextCloudPi
+
+Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
+GPL licensed (see LICENSE file in repository root).
+Use at your own risk!
+
+ ./tests.py <IP>
+More at https://ownyourbits.com
+"""
+
+import unittest
+import sys
+import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
-import unittest
-import pexpect
-import sys
-import time
IP = sys.argv[1]
-#
-# Login as Admin user and assert that all internal checks pass ( All checks passed! tick )
-# Also checks for correct trusted domain setting
-#
class AdminWebTest(unittest.TestCase):
+ """
+ Log as admin and assert that all internal checks pass ("All checks passed!")
+ Also checks for correct trusted domain setting
+ """
def setUp(self):
self.driver = webdriver.Firefox()
- #@unittest.skip("Skipping...")
- def test_login(self):
+ # @unittest.skip("Skipping...")
+ def test_admin_checks(self):
+ """ Login and assert admin page checks"""
driver = self.driver
- driver.implicitly_wait(150) # first run can be really slow on QEMU
+ driver.implicitly_wait(150) # first run can be really slow on QEMU
driver.get("https://" + IP + "/index.php/settings/admin")
self.assertIn("Nextcloud", driver.title)
- self.assertNotIn ( "You are accessing the server from an untrusted domain" , driver.page_source )
+ trusted_domain_str = "You are accessing the server from an untrusted domain"
+ self.assertNotIn(trusted_domain_str, driver.page_source)
driver.find_element_by_id("user").send_keys("admin")
driver.find_element_by_id("password").send_keys("ownyourbits")
driver.find_element_by_id("submit").click()
- self.assertNotIn ( "Wrong password" , driver.page_source )
+ self.assertNotIn("Wrong password", driver.page_source)
wait = WebDriverWait(driver, 150)
- element = wait.until(EC.visibility_of(driver.find_element_by_class_name("icon-checkmark")))
+ wait.until(EC.visibility_of(driver.find_element_by_class_name("icon-checkmark")))
def tearDown(self):
self.driver.close()
-#
-# Create a user, then navigate a little bit
-#
-
class CreateUserTest(unittest.TestCase):
+ """
+ Create a user, then navigate a little bit
+ """
def setUp(self):
self.driver = webdriver.Firefox()
- #@unittest.skip("Skipping...")
- def test_login(self):
+ # @unittest.skip("Skipping...")
+ def test_user_creation(self):
+ """ Create user test_user1 """
driver = self.driver
driver.get("https://" + IP + "/index.php/settings/users")
driver.find_element_by_id("user").send_keys("admin")
driver.find_element_by_id("password").send_keys("ownyourbits")
driver.find_element_by_id("submit").click()
- self.assertNotIn ( "Wrong password" , driver.page_source )
+ self.assertNotIn("Wrong password", driver.page_source)
wait = WebDriverWait(driver, 150)
wait.until(lambda driver: driver.find_element_by_id("newusername"))
@@ -77,7 +80,7 @@ class CreateUserTest(unittest.TestCase):
driver.find_element_by_id("newuserpassword").send_keys("ownyourbits")
driver.find_element_by_id("newuserpassword").send_keys(Keys.RETURN)
- time.sleep( 5 )
+ time.sleep(5)
# navigate a little bit
driver.get("https://" + IP + "/index.php/settings/admin")
@@ -88,18 +91,20 @@ class CreateUserTest(unittest.TestCase):
def tearDown(self):
self.driver.close()
-#
-# Login as the newly created user and check that we are in the Files App
-#
class LoginNewUserTest(unittest.TestCase):
+ """
+ Login as the newly created user and check that we are in the Files App
+ """
def setUp(self):
self.driver = webdriver.Firefox()
- #@unittest.skip("Skipping...")
- def test_login(self):
+ # @unittest.skip("Skipping...")
+ def test_user_login(self):
+ """ Login as test_user1 """
driver = self.driver
+ driver.implicitly_wait(210) # first run can be really slow on QEMU
driver.get("https://" + IP)
self.assertIn("Nextcloud", driver.title)
@@ -107,7 +112,8 @@ class LoginNewUserTest(unittest.TestCase):
driver.find_element_by_id("password").send_keys("ownyourbits")
driver.find_element_by_id("submit").click()
- wait = WebDriverWait(driver, 60)
+ time.sleep(60) # first run can be really slow on QEMU
+ wait = WebDriverWait(driver, 210)
wait.until(lambda driver: driver.find_element_by_id("fileList"))
# navigate a little bit
@@ -117,12 +123,13 @@ class LoginNewUserTest(unittest.TestCase):
def tearDown(self):
self.driver.close()
+
if __name__ == "__main__":
if len(sys.argv) != 2:
- print( "IP argument required" )
+ print("IP argument required")
sys.exit()
- unittest.main(argv=['first-arg-is-ignored'],verbosity=2)
+ unittest.main(argv=['first-arg-is-ignored'], verbosity=2)
# License
#
@@ -140,4 +147,3 @@ if __name__ == "__main__":
# along with this script; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
-