-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_no_refs.py
81 lines (69 loc) · 2.05 KB
/
test_no_refs.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from unittest import TestCase
from unittest.mock import patch
from no_refs import Finder
from io import StringIO
import logging
class ProcessStreamTest(TestCase):
def setUp(self):
self.finder = Finder()
@patch('no_refs.console_logger')
def test_empty_input_produces_no_output(self, logger):
stream = StringIO("")
self.finder.process_stream(stream, "path")
logger.assert_not_called()
@patch('no_refs.console_logger')
def test_no_page_node_produces_no_output(self, logger):
stream = StringIO("""
<mediawiki>
</mediawiki>
""")
self.finder.process_stream(stream, "path")
logger.assert_not_called()
@patch('no_refs.console_logger')
def test_no_revision_node_produces_no_output(self, logger):
stream = StringIO("""
<mediawiki>
<page>
<ns>0</ns>
</page>
</mediawiki>
""")
self.finder.process_stream(stream, "path")
logger.assert_not_called()
@patch('no_refs.console_logger')
def test_empty_text_produces_no_output(self, logger):
stream = StringIO("""
<mediawiki>
<page>
<title>Title</title>
<ns>0</ns>
<id>1</id>
<revision>
<id>2</id>
<text>
</text>
</revision>
</page>
</mediawiki>
""")
self.finder.process_stream(stream, "path")
logger.info.assert_not_called()
@patch('no_refs.console_logger')
def test_one_revision_with_matching_text_finds_page(self, logger):
stream = StringIO("""
<mediawiki>
<page>
<title>Title 1</title>
<ns>0</ns>
<id>1</id>
<revision>
<id>2</id>
<text>
living people
</text>
</revision>
</page>
</mediawiki>
""")
self.finder.process_stream(stream, "path")
logger.info.assert_called_once_with("Title 1")