| 
3 | 3 | 
 
  | 
4 | 4 | from nlp import loadPageHTML, stripRawHTML, findOutlinks, onlyWikipediaURLS  | 
5 | 5 | from nlp import expand_pages, relevant_pages, normalize, ConvergenceDetector, getInlinks  | 
6 |  | -from nlp import getOutlinks, Page  | 
 | 6 | +from nlp import getOutlinks, Page, determineInlinks, HITS  | 
7 | 7 | from nlp import Rules, Lexicon  | 
8 | 8 | # Clumsy imports because we want to access certain nlp.py globals explicitly, because  | 
9 | 9 | # they are accessed by function's within nlp.py  | 
@@ -80,9 +80,9 @@ def test_stripRawHTML(html_mock):  | 
80 | 80 | 
 
  | 
81 | 81 | 
 
  | 
82 | 82 | def test_determineInlinks():  | 
83 |  | -    # TODO  | 
84 |  | -    assert True  | 
85 |  | - | 
 | 83 | +    assert set(determineInlinks(pA)) == set(['B', 'C', 'E'])  | 
 | 84 | +    assert set(determineInlinks(pE)) == set([])  | 
 | 85 | +    assert set(determineInlinks(pF)) == set(['E'])  | 
86 | 86 | 
 
  | 
87 | 87 | def test_findOutlinks_wiki():  | 
88 | 88 |     testPage = pageDict[pA.address]  | 
@@ -141,17 +141,20 @@ def test_detectConvergence():  | 
141 | 141 | 
 
  | 
142 | 142 | def test_getInlinks():  | 
143 | 143 |     inlnks = getInlinks(pageDict['A'])  | 
144 |  | -    assert sorted([page.address for page in inlnks]) == pageDict['A'].inlinks  | 
 | 144 | +    assert sorted(inlnks) == pageDict['A'].inlinks  | 
145 | 145 | 
 
  | 
146 | 146 | 
 
  | 
147 | 147 | def test_getOutlinks():  | 
148 | 148 |     outlnks = getOutlinks(pageDict['A'])  | 
149 |  | -    assert sorted([page.address for page in outlnks]) == pageDict['A'].outlinks  | 
 | 149 | +    assert sorted(outlnks) == pageDict['A'].outlinks  | 
150 | 150 | 
 
  | 
151 | 151 | 
 
  | 
152 | 152 | def test_HITS():  | 
153 |  | -    # TODO  | 
154 |  | -    assert True  # leave for now  | 
 | 153 | +    HITS('inherit')  | 
 | 154 | +    auth_list = [pA.authority, pB.authority, pC.authority, pD.authority, pE.authority, pF.authority]  | 
 | 155 | +    hub_list = [pA.hub, pB.hub, pC.hub, pD.hub, pE.hub, pF.hub]  | 
 | 156 | +    assert max(auth_list) == pD.authority  | 
 | 157 | +    assert max(hub_list) == pE.hub  | 
155 | 158 | 
 
  | 
156 | 159 | 
 
  | 
157 | 160 | if __name__ == '__main__':  | 
 | 
0 commit comments