-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_relink.py
45 lines (38 loc) · 956 Bytes
/
test_relink.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from extract import Extract
from relink import *
#from test_extract import ANCHOR
from pathlib import Path
from pytest import fixture
TEST_MHT='sample.mhtml'
TEST_ANCHOR='h4'
@fixture
def soup():
ex = Extract(TEST_MHT)
rel = relink(ex, TEST_ANCHOR)
return ex.soup
def test_rel(soup):
assert soup
def test_toc(soup):
print(RID_TOC)
toc = soup.find(id=RID_TOC)
assert toc
assert 'List' in str(toc)
assert RID in toc['id']
assert len(toc.contents) > 1
olist = toc.contents[1]
item = olist.contents[0]
anchor = item.contents[0]
assert anchor
assert RID in anchor['href']
def untest_div(soup):
sib = soup.find(class_=RID_PARENT)
print(str(soup.body.div.div.div)[500:1000])
assert sib
assert sib['class']
assert RID_PARENT in sib['class']
def untest_find_anchor(soup):
#print(soup.body.div.div.prettify())
# ONLY works if `sibling.insert_after(tadd(toc, links))`
result = soup.findAll('h4')
assert result
assert len(result) == 40