113
119
# The sample data already contains one submission.
114
120
submissions = loop.getUnprocessedSubmissions(2)
115
121
self.assertEqual([submission2], submissions)
123
# XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
124
def xxx_test_run_reprocessing_script_no_params(self):
125
# cronscripts/reprocess-hwdb-submissions.py needs at least the
126
# parameter --start-file
127
retcode, stdout, stderr = run_script(
128
'cronscripts/reprocess-hwdb-submissions.py', [])
130
stderr, Contains('Option --start-file not specified.'))
132
# XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
133
def xxx_test_run_reprocessing_script_startfile_does_not_exist(self):
134
# If the specified start file does not exist,
135
# cronscripts/reprocess-hwdb-submissions.py reports an error.
136
does_not_exist = mktemp()
137
retcode, stdout, stderr = run_script(
138
'cronscripts/reprocess-hwdb-submissions.py',
139
['--start-file', does_not_exist])
141
stderr, Contains('Cannot access file %s' % does_not_exist))
143
# XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
144
def xxx_test_run_reprocessing_script_startfile_without_integer(self):
145
# If the specified start file contains any non-integer string,
146
# cronscripts/reprocess-hwdb-submissions.py reports an error.
147
start_file_name = mktemp()
148
start_file = open(start_file_name, 'w')
149
start_file.write('nonsense')
151
retcode, stdout, stderr = run_script(
152
'cronscripts/reprocess-hwdb-submissions.py',
153
['--start-file', start_file_name])
156
Contains('%s must contain only an integer' % start_file_name))
158
# XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
159
def xxx_test_run_reprocessing_script_startfile_with_negative_integer(self):
160
# If the specified start file contains any non-integer string,
161
# cronscripts/reprocess-hwdb-submissions.py reports an error.
162
start_file_name = mktemp()
163
start_file = open(start_file_name, 'w')
164
start_file.write('-1')
166
retcode, stdout, stderr = run_script(
167
'cronscripts/reprocess-hwdb-submissions.py',
168
['--start-file', start_file_name])
171
Contains('%s must contain a positive integer' % start_file_name))
173
# XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
174
def xxx_test_run_reprocessing_script_max_submission_not_integer(self):
175
# If the parameter --max-submissions is not an integer,
176
# cronscripts/reprocess-hwdb-submissions.py reports an error.
177
retcode, stdout, stderr = run_script(
178
'cronscripts/reprocess-hwdb-submissions.py',
179
['--max-submissions', 'nonsense'])
180
expected = "Invalid value for --max_submissions specified: 'nonsense'"
181
self.assertThat(stderr, Contains(expected))
183
def test_run_reprocessing_script_two_batches(self):
184
# cronscripts/reprocess-hwdb-submissions.py begings to process
185
# submissions with IDs starting at the value stored in the
186
# file given as the parameter --start-file. When is has
187
# finished processing the number of submissions specified by
188
# --max-submissions, it stores the ID of the last prcessed
189
# submission in start-file.
191
for count in range(5):
192
new_submissions.append(
193
self.factory.makeHWSubmission(
194
status=HWSubmissionProcessingStatus.INVALID))
196
start_file_name = mktemp()
197
start_file = open(start_file_name, 'w')
198
start_file.write('%i' % new_submissions[1].id)
201
Store.of(new_submissions[0]).invalidate()
203
retcode, stdout, stderr = run_script(
204
'cronscripts/reprocess-hwdb-submissions.py',
205
['--max-submissions', '2', '--start-file', start_file_name])
207
# We started with the ID of the second submission created abvoe,
208
# so the first submission still has the status INVALID.
210
HWSubmissionProcessingStatus.INVALID,
211
new_submissions[0].status)
212
# We processed two submissions, they now have the status
215
HWSubmissionProcessingStatus.PROCESSED,
216
new_submissions[1].status)
218
HWSubmissionProcessingStatus.PROCESSED,
219
new_submissions[2].status)
220
# The following submissions were not yet touched,
222
HWSubmissionProcessingStatus.INVALID,
223
new_submissions[3].status)
225
HWSubmissionProcessingStatus.INVALID,
226
new_submissions[4].status)
228
# The start file now contains the ID of the 4th submission.
229
new_start = int(open(start_file_name).read())
230
self.assertEqual(new_submissions[3].id, new_start)
232
# When we run the script again, for only one submission,
233
# the 4th submission is processed.
235
Store.of(new_submissions[0]).invalidate()
236
retcode, stdout, stderr = run_script(
237
'cronscripts/reprocess-hwdb-submissions.py',
238
['--max-submissions', '1', '--start-file', start_file_name])
240
HWSubmissionProcessingStatus.PROCESSED,
241
new_submissions[3].status)
243
HWSubmissionProcessingStatus.INVALID,
244
new_submissions[4].status)