"""))
parsed = html.fromstring(data)
parsed.write = mock.Mock()
with mock.patch('bin.post_version.html.parse',
mock.Mock(return_value=parsed)):
post_version.update_calendar('19.2.3')
assert len(parsed.findall('.//tr')) == 3
# we need the second element becouse the first is the header
tr = parsed.findall('.//tr')[1]
tds = tr.findall('.//td')
assert tds[0].get("rowspan") == "2"
assert tds[0].text == "19.2"
assert tds[1].text == "2019-11-20"
@pytest.fixture
def two_releases(self) -> html.etree.ElementTree:
data = self.wrap_table(textwrap.dedent("""\
19.1
2019-11-06
19.1.8
Not Dylan Baker
19.2
2019-11-06
19.2.3
Dylan Baker
2019-11-20
19.2.4
Dylan Baker
2019-12-04
19.2.5
Dylan Baker
Last planned 19.2.x release
"""))
p = html.fromstring(data)
p.write = mock.Mock()
return p
def test_two_releases(self, two_releases: html.etree.ElementTree):
with mock.patch('bin.post_version.html.parse',
mock.Mock(return_value=two_releases)):
post_version.update_calendar('19.2.3')
assert len(two_releases.findall('.//tr')) == 4
# we need the second element becouse the first is the header
tr = two_releases.findall('.//tr')[2]
tds = tr.findall('.//td')
assert tds[0].get("rowspan") == "2"
assert tds[0].text == "19.2"
assert tds[1].text == "2019-11-20"
def test_last_Release(self, two_releases: html.etree.ElementTree):
with mock.patch('bin.post_version.html.parse',
mock.Mock(return_value=two_releases)):
post_version.update_calendar('19.1.8')
assert len(two_releases.findall('.//tr')) == 4
# we need the second element becouse the first is the header
tr = two_releases.findall('.//tr')[1]
tds = tr.findall('.//td')
assert tds[0].get("rowspan") == "3"
assert tds[0].text == "19.2"
assert tds[1].text == "2019-11-06"