Browse Source

Py3: Add submitting of Config pages to basic functional test

Easy way to find crashes
pull/1253/head
Safihre 6 years ago
parent
commit
638e87515a
  1. 46
      tests/test_functional.py
  2. 5
      tests/test_misc.py

46
tests/test_functional.py

@ -23,7 +23,7 @@ import unittest
import random
from selenium import webdriver
from selenium.common.exceptions import WebDriverException, NoSuchElementException
from selenium.common.exceptions import WebDriverException, NoSuchElementException, UnexpectedAlertPresentException
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from selenium.webdriver.common.keys import Keys
@ -88,20 +88,50 @@ class SABnzbdBasicPagesTest(SABnzbdBaseTest):
def test_base_pages(self):
# Quick-check of all Config pages
test_urls = ['config',
'config/general',
'config/folders',
'config/server',
'config/categories',
'config/switches',
'config/sorting',
'config/notify',
'config/scheduling',
'config/rss',
'config/special']
'config/rss']
for test_url in test_urls:
self.open_page("http://%s:%s/%s" % (SAB_HOST, SAB_PORT, test_url))
def test_base_submit_pages(self):
test_urls_with_submit = ['config/general',
'config/folders',
'config/switches',
'config/sorting',
'config/notify',
'config/special']
for test_url in test_urls_with_submit:
self.open_page("http://%s:%s/%s" % (SAB_HOST, SAB_PORT, test_url))
# Can only click the visible buttons
submit_btns = self.driver.find_elements_by_class_name('saveButton')
for submit_btn in submit_btns:
if submit_btn.is_displayed():
break
else:
raise NoSuchElementException
# Click the right button
submit_btn.click()
try:
self.wait_for_ajax()
except UnexpectedAlertPresentException:
# Ignore restart-request due to empty sabnzbd.ini in tests
self.driver.switch_to.alert.dismiss()
# For Specials page we get redirected after save, so check for no crash
if 'special' in test_url:
self.no_page_crash()
else:
# For others if all is fine, button will be back to normal in 1 second
time.sleep(1.0)
assert submit_btn.text == "Save Changes"
class SABnzbdConfigCategories(SABnzbdBaseTest):

5
tests/test_misc.py

@ -51,8 +51,9 @@ class TestMisc:
self.assertTime('1d', d)
def test_monthrange(self):
min_date = datetime.date.today() - datetime.timedelta(days=350)
assert 12 == len(list(misc.monthrange(min_date, datetime.date.today())))
# Dynamic dates would be a problem
assert 12 == len(list(misc.monthrange(datetime.date(2018, 1, 1), datetime.date(2018, 12, 31))))
assert 2 == len(list(misc.monthrange(datetime.date(2019, 1, 1), datetime.date(2019, 2, 1))))
def test_safe_lower(self):
assert 'all caps' == misc.safe_lower('ALL CAPS')

Loading…
Cancel
Save