mirror of
https://github.com/TrentSPalmer/hugo_themes_report.git
synced 2024-12-04 16:41:31 -08:00
add unittest test_title
This commit is contained in:
parent
beb1bdadba
commit
4dec9f77c9
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
hugothemes.db
|
hugothemes.db
|
||||||
__pycache__
|
__pycache__
|
||||||
|
test/__pycache__
|
||||||
hugo-themes-report
|
hugo-themes-report
|
||||||
hugo_themes_report.log
|
hugo_themes_report.log
|
||||||
|
20
test/README.md
Normal file
20
test/README.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
To run these tests just type the command
|
||||||
|
```python
|
||||||
|
python3 -m unittest
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you can just run a specific file of tests
|
||||||
|
|
||||||
|
```python
|
||||||
|
python3 -m unittest test.test_title
|
||||||
|
```
|
||||||
|
|
||||||
|
Or run a specific test class in a specific file
|
||||||
|
```python
|
||||||
|
python3 -m unittest test.test_title.TestTitle
|
||||||
|
```
|
||||||
|
|
||||||
|
Or run a specific test function in a specific class in a specific file
|
||||||
|
```python
|
||||||
|
python3 -m unittest test.test_title.TestTitle.test_title_anchor
|
||||||
|
```
|
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
21
test/test_selenium.py
Normal file
21
test/test_selenium.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
from selenium import webdriver
|
||||||
|
from selenium.webdriver.chrome.service import Service
|
||||||
|
from selenium.webdriver.chrome.options import Options
|
||||||
|
OPTIONS = Options()
|
||||||
|
OPTIONS.add_argument('--ignore-certificate-errors')
|
||||||
|
OPTIONS.add_argument('--incognito')
|
||||||
|
OPTIONS.add_argument('--headless')
|
||||||
|
SERVICE = Service('/usr/bin/chromedriver')
|
||||||
|
SOURCE_FILE = Path('hugo-themes-report/hugo-themes-report.html').resolve()
|
||||||
|
SOURCE_PAGE = f'file://{str(SOURCE_FILE)}'
|
||||||
|
|
||||||
|
|
||||||
|
class TestSelenium(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.driver = webdriver.Chrome(options=OPTIONS, service=SERVICE)
|
||||||
|
self.driver.get(SOURCE_PAGE)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.driver.quit()
|
24
test/test_title.py
Normal file
24
test/test_title.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from test.test_selenium import TestSelenium
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class TestTitle(TestSelenium, unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestTitle, self).setUp()
|
||||||
|
self.x = self.driver.find_elements_by_tag_name('h1')
|
||||||
|
|
||||||
|
def test_title(self):
|
||||||
|
self.assertEqual(len(self.x), 1)
|
||||||
|
self.assertEqual(self.x[0].get_attribute('id'), 'title')
|
||||||
|
self.assertEqual(self.x[0].value_of_css_property('text-align'), 'center')
|
||||||
|
self.assertEqual(self.x[0].value_of_css_property('display'), 'block')
|
||||||
|
self.assertEqual(self.x[0].value_of_css_property('max-width'), '736px')
|
||||||
|
self.assertEqual(self.x[0].value_of_css_property('font-size'), '32px')
|
||||||
|
self.assertEqual(self.x[0].value_of_css_property('font-weight'), '700')
|
||||||
|
self.assertEqual(self.x[0].value_of_css_property('font-family'), 'sans-serif')
|
||||||
|
|
||||||
|
def test_title_anchor(self):
|
||||||
|
x_anchors = self.x[0].find_elements_by_tag_name('a')
|
||||||
|
self.assertEqual(len(x_anchors), 1)
|
||||||
|
self.assertEqual(x_anchors[0].get_attribute('href'), 'https://github.com/TrentSPalmer/hugo_themes_report')
|
||||||
|
self.assertEqual(x_anchors[0].get_attribute('target'), '_blank')
|
Loading…
Reference in New Issue
Block a user