1
Fork 0

Use settings in tests

This commit is contained in:
Jake Howard 2017-05-22 09:53:46 +01:00
parent d6234e155b
commit a1afb64600
3 changed files with 8 additions and 2 deletions

View file

@ -1,4 +1,5 @@
beautifulsoup4==4.6.0
nose2==0.6.5
pygments
pyyaml==3.12

View file

@ -1,6 +1,9 @@
import unittest
import os.path
from bs4 import BeautifulSoup
import yaml
SETTINGS = yaml.safe_load(open(os.path.realpath('./config.yml')))
class TestClient:
@ -17,8 +20,8 @@ class TestClient:
return content
def build_path(self, path):
if path.startswith('https://theorangeone.net'):
path = path.replace('https://theorangeone.net', '')
if path.startswith(SETTINGS['baseURL']):
path = path.replace(SETTINGS['baseURL'], '')
if path.startswith('/'):
path = path[1:]
if path.endswith('/'):
@ -31,6 +34,7 @@ class TestClient:
class TestCase(unittest.TestCase):
client = TestClient()
settings = SETTINGS
def get_children(self, content):
return str(list(content.children)[0]).strip()

View file

@ -27,6 +27,7 @@ class CommonPagesTestCase(TestCase):
self.assertEqual(len(tab.find_all('ul')), 0)
self.assertTrue(self.client.exists(tab.find('a').attrs['href']))
else:
self.assertLessEqual(len(tab.find_all('a')), self.settings['params']['nav_items'] + 2)
for link in tab.find_all('a'):
self.assertTrue(self.client.exists(link.attrs['href']))
self.assertNotEqual(self.get_children(link), '')