Merge lp:~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056 into lp:launchpad

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: not available
Merged at revision: 15140
Proposed branch: lp:~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056
Merge into: lp:launchpad
Diff against target: 92 lines (+16/-13)
1 file modified
lib/lp/hardwaredb/scripts/tests/test_hwdbsubmissions.py (+16/-13)
To merge this branch: bzr merge lp:~gmb/launchpad/mark-db-dirty-for-cronscripts-bug-849056
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+103084@code.launchpad.net

Commit message

HWDB tests that run cronscripts now explicitly mark the DB dirty, fixing bug 849056.

Description of the change

This branch fixes bug 849056 by following William's advice and having all the tests that just run cronscripts explicitly mark the DB dirty.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

Looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/hardwaredb/scripts/tests/test_hwdbsubmissions.py'
2--- lib/lp/hardwaredb/scripts/tests/test_hwdbsubmissions.py 2012-01-01 02:58:52 +0000
3+++ lib/lp/hardwaredb/scripts/tests/test_hwdbsubmissions.py 2012-04-23 12:00:27 +0000
4@@ -16,7 +16,10 @@
5 ProcessingLoopForReprocessingBadSubmissions,
6 )
7 from lp.testing import TestCaseWithFactory
8-from lp.testing.layers import LaunchpadScriptLayer
9+from lp.testing.layers import (
10+ DatabaseLayer,
11+ LaunchpadScriptLayer,
12+ )
13 from lp.testing.matchers import Contains
14 from lp.testing.script import run_script
15
16@@ -108,8 +111,7 @@
17 submissions = loop.getUnprocessedSubmissions(1)
18 self.assertEqual(1, len(submissions))
19
20- # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
21- def xxx_test_BadSubmissions_respects_start(self):
22+ def test_BadSubmissions_respects_start(self):
23 # It is possible to request a start id. Previous entries are ignored.
24 submission1 = self.factory.makeHWSubmission(
25 status=HWSubmissionProcessingStatus.INVALID)
26@@ -120,18 +122,18 @@
27 # The sample data already contains one submission.
28 submissions = loop.getUnprocessedSubmissions(2)
29 self.assertEqual([submission2], submissions)
30+ DatabaseLayer.force_dirty_database()
31
32- # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
33- def xxx_test_run_reprocessing_script_no_params(self):
34+ def test_run_reprocessing_script_no_params(self):
35 # cronscripts/reprocess-hwdb-submissions.py needs at least the
36 # parameter --start-file
37 retcode, stdout, stderr = run_script(
38 'cronscripts/reprocess-hwdb-submissions.py', [])
39 self.assertThat(
40 stderr, Contains('Option --start-file not specified.'))
41+ DatabaseLayer.force_dirty_database()
42
43- # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
44- def xxx_test_run_reprocessing_script_startfile_does_not_exist(self):
45+ def test_run_reprocessing_script_startfile_does_not_exist(self):
46 # If the specified start file does not exist,
47 # cronscripts/reprocess-hwdb-submissions.py reports an error.
48 does_not_exist = mktemp()
49@@ -140,9 +142,9 @@
50 ['--start-file', does_not_exist])
51 self.assertThat(
52 stderr, Contains('Cannot access file %s' % does_not_exist))
53+ DatabaseLayer.force_dirty_database()
54
55- # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
56- def xxx_test_run_reprocessing_script_startfile_without_integer(self):
57+ def test_run_reprocessing_script_startfile_without_integer(self):
58 # If the specified start file contains any non-integer string,
59 # cronscripts/reprocess-hwdb-submissions.py reports an error.
60 start_file_name = mktemp()
61@@ -155,9 +157,9 @@
62 self.assertThat(
63 stderr,
64 Contains('%s must contain only an integer' % start_file_name))
65+ DatabaseLayer.force_dirty_database()
66
67- # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
68- def xxx_test_run_reprocessing_script_startfile_with_negative_integer(self):
69+ def test_run_reprocessing_script_startfile_with_negative_integer(self):
70 # If the specified start file contains any non-integer string,
71 # cronscripts/reprocess-hwdb-submissions.py reports an error.
72 start_file_name = mktemp()
73@@ -170,9 +172,9 @@
74 self.assertThat(
75 stderr,
76 Contains('%s must contain a positive integer' % start_file_name))
77+ DatabaseLayer.force_dirty_database()
78
79- # XXX 2011-09-13, Abel Deuring: Disabled due to bug 849056.
80- def xxx_test_run_reprocessing_script_max_submission_not_integer(self):
81+ def test_run_reprocessing_script_max_submission_not_integer(self):
82 # If the parameter --max-submissions is not an integer,
83 # cronscripts/reprocess-hwdb-submissions.py reports an error.
84 retcode, stdout, stderr = run_script(
85@@ -180,6 +182,7 @@
86 ['--max-submissions', 'nonsense'])
87 expected = "Invalid value for --max_submissions specified: 'nonsense'"
88 self.assertThat(stderr, Contains(expected))
89+ DatabaseLayer.force_dirty_database()
90
91 def test_run_reprocessing_script_two_batches(self):
92 # cronscripts/reprocess-hwdb-submissions.py begings to process