From a1afb64600b1adb7b13f316e522666c5414131cd Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 22 May 2017 09:53:46 +0100 Subject: [PATCH] Use settings in tests --- requirements.txt | 1 + tests/__init__.py | 8 ++++++-- tests/tests_common.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index ada17de..c960a34 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ beautifulsoup4==4.6.0 nose2==0.6.5 pygments +pyyaml==3.12 diff --git a/tests/__init__.py b/tests/__init__.py index fa423e5..324f23a 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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() diff --git a/tests/tests_common.py b/tests/tests_common.py index 55a3103..181ea43 100644 --- a/tests/tests_common.py +++ b/tests/tests_common.py @@ -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), '')