mirror of
https://github.com/TrentSPalmer/hugo_themes_report.git
synced 2024-12-04 16:41:31 -08:00
add test_filterby_minver.py
This commit is contained in:
parent
152074386e
commit
30e0067245
58
test/test_filterby_minver.py
Normal file
58
test/test_filterby_minver.py
Normal file
@ -0,0 +1,58 @@
|
||||
from test.test_selenium import TestSelenium
|
||||
from unittest import TestCase
|
||||
from test.database import get_themes_orderedby_cname
|
||||
from test.theme_compare import semver_split, compare_jk
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
class TestFilterByMinVer(TestSelenium, TestCase):
|
||||
def setUp(self):
|
||||
super(TestFilterByMinVer, self).setUp()
|
||||
for x in [
|
||||
'plus-button',
|
||||
'button-for-showing-columns',
|
||||
'min_ver-column-selection-input',
|
||||
'button-for-showing-sort-option',
|
||||
'sortByName',
|
||||
'button-for-filter-by-minver',
|
||||
]:
|
||||
self.driver.find_element_by_id(x).click()
|
||||
self.themes = get_themes_orderedby_cname()
|
||||
|
||||
def test_filter_by_min_ver(self):
|
||||
filterby_mv_inputs = [x.get_attribute('id')[0:-33]
|
||||
for x in self.driver.find_element_by_id(
|
||||
'minVerSelectionRow').find_elements_by_tag_name('input')]
|
||||
|
||||
for m_ver in filterby_mv_inputs:
|
||||
self.driver.find_element_by_id(
|
||||
f'{m_ver}-select-minver-radio-button-input').click()
|
||||
if m_ver == 'none':
|
||||
themes = self.themes
|
||||
else:
|
||||
split_mver = semver_split(m_ver)
|
||||
themes = list(
|
||||
filter(
|
||||
lambda x: x.min_ver is not None and compare_jk(
|
||||
split_mver, semver_split(x.min_ver)
|
||||
) != 1, self.themes
|
||||
)
|
||||
)
|
||||
results_table_div = self.driver.find_element_by_id('results')
|
||||
rows = BeautifulSoup(results_table_div.get_attribute(
|
||||
'innerHTML'), features='lxml').find('table').findAll('tr')
|
||||
|
||||
for i, row in enumerate(rows[1:]):
|
||||
tds = row.findAll('td')
|
||||
tds_txt = [x.text for x in tds]
|
||||
|
||||
self.assertEqual(
|
||||
tds_txt,
|
||||
[
|
||||
themes[i].cname,
|
||||
themes[i].commit_date[0:10],
|
||||
str(themes[i].stargazers_count),
|
||||
themes[i].commit_sha[0:6],
|
||||
'' if themes[i].min_ver is None else themes[i].min_ver,
|
||||
],
|
||||
)
|
Loading…
Reference in New Issue
Block a user