← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:fix-remove-hardwaredb-sampledata into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-remove-hardwaredb-sampledata into launchpad:master.

Commit message:
Fix close-account test to fill in more hardware DB rows by hand

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/399425

Now that we've removed hardware database rows from sampledata, test_handles_hardware_submissions needs to do a bit more work to set things up to match the sort of historical data that might exist on production.  (While this is a little more awkward, it's still a reasonable trade-off against having to copy those rows around every time we restore the test database from a template.)
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-remove-hardwaredb-sampledata into launchpad:master.
diff --git a/lib/lp/registry/scripts/tests/test_closeaccount.py b/lib/lp/registry/scripts/tests/test_closeaccount.py
index 24b5be5..f5afc52 100644
--- a/lib/lp/registry/scripts/tests/test_closeaccount.py
+++ b/lib/lp/registry/scripts/tests/test_closeaccount.py
@@ -447,18 +447,25 @@ class TestCloseAccount(TestCaseWithFactory):
                  date_created, keys[1], self.factory.makePerson().id,
                  raw_submissions[1].id, system_fingerprint_ids[1]))]
         with dbuser('hwdb-submission-processor'):
+            vendor_name_id = store.execute("""
+                INSERT INTO HWVendorName (name) VALUES (?) RETURNING id
+                """, (self.factory.getUniqueUnicode(),)).get_one()[0]
+            vendor_id = store.execute("""
+                INSERT INTO HWVendorID (bus, vendor_id_for_bus, vendor_name)
+                VALUES (1, '0x0001', ?)
+                RETURNING id
+                """, (vendor_name_id,)).get_one()[0]
+            device_id = store.execute("""
+                INSERT INTO HWDevice
+                    (bus_vendor_id, bus_product_id, variant, name, submissions)
+                VALUES (?, '0x0002', NULL, ?, 1)
+                RETURNING id
+                """, (vendor_id, self.factory.getUniqueUnicode())).get_one()[0]
             device_driver_link_id = store.execute("""
-                SELECT HWDeviceDriverLink.id
-                FROM HWDeviceDriverLink, HWDevice, HWVendorID
-                WHERE
-                    HWVendorID.bus = 1
-                    AND HWVendorID.vendor_id_for_bus = '0x10de'
-                    AND HWDevice.bus_vendor_id = HWVendorID.id
-                    AND HWDevice.bus_product_id = '0x0455'
-                    AND HWDevice.variant IS NULL
-                    AND HWDeviceDriverLink.device = HWDevice.id
-                    AND HWDeviceDriverLink.driver IS NULL
-                """).get_one()[0]
+                INSERT INTO HWDeviceDriverLink (device, driver)
+                VALUES (?, NULL)
+                RETURNING id
+                """, (device_id,)).get_one()[0]
             parent_submission_device_id = store.execute("""
                 INSERT INTO HWSubmissionDevice
                     (device_driver_link, submission, parent, hal_device_id)