69
70
self.assertThat(parser.getBugs(), Equals({}))
71
72
def test_passing(self):
72
data = ['ignored,id,resolution,status',
73
'foo,42,not,complete',
74
'ignored,id,resolution,status',
75
'foo,42,not,complete',
75
78
parser = MantisBugBatchParser(data, self.logger)
77
80
id=42, status='complete', resolution='not', ignored='foo')
80
83
self.assertThat(parser.getBugs(), Equals({42: bug_42, 13: bug_13}))
82
85
def test_incomplete_line(self):
83
data = ['ignored,id,resolution,status',
87
'ignored,id,resolution,status',
85
90
parser = MantisBugBatchParser(data, self.logger)
86
91
self.assertThat(parser.getBugs(), Equals({}))
87
92
log = self.logger.getLogBuffer()
89
log, Equals("WARNING Line ['42', 'not', 'complete'] incomplete.\n"))
95
Equals("WARNING Line ['42', 'not', 'complete'] incomplete.\n"))
91
97
def test_non_integer_id(self):
92
data = ['ignored,id,resolution,status',
93
'foo,bar,not,complete']
99
'ignored,id,resolution,status',
100
'foo,bar,not,complete',
94
102
parser = MantisBugBatchParser(data, self.logger)
95
103
self.assertThat(parser.getBugs(), Equals({}))
96
104
log = self.logger.getLogBuffer()
107
115
# If the 'view_all_set.php' request raises a 404, then the csv_data
108
116
# attribute is None.
109
117
base_url = "http://example.com/"
110
def raise404(self, request, data):
111
raise urllib2.HTTPError('url', 404, 'Not Found', None, None)
112
with monkey_patch(Mantis, urlopen=raise404):
119
fail_404 = urllib2.HTTPError('url', 404, 'Not Found', None, None)
121
with monkey_patch(Mantis, urlopen=FakeMethod(failure=fail_404)):
113
122
bugtracker = Mantis(base_url)
114
123
self.assertThat(bugtracker.csv_data, Is(None))