← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:stormify-binaryandsourcepackagename into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:stormify-binaryandsourcepackagename into launchpad:master.

Commit message:
Convert BinaryAndSourcePackageName to Storm

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/388954
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:stormify-binaryandsourcepackagename into launchpad:master.
diff --git a/lib/lp/app/widgets/tests/test_launchpadtarget.py b/lib/lp/app/widgets/tests/test_launchpadtarget.py
index 2cfbf28..147e44d 100644
--- a/lib/lp/app/widgets/tests/test_launchpadtarget.py
+++ b/lib/lp/app/widgets/tests/test_launchpadtarget.py
@@ -1,6 +1,8 @@
-# Copyright 2011-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import re
diff --git a/lib/lp/bugs/browser/tests/test_bugtask.py b/lib/lp/bugs/browser/tests/test_bugtask.py
index b134c89..dd33206 100644
--- a/lib/lp/bugs/browser/tests/test_bugtask.py
+++ b/lib/lp/bugs/browser/tests/test_bugtask.py
@@ -1,6 +1,8 @@
-# Copyright 2009-2019 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 from datetime import (
@@ -309,7 +311,7 @@ class TestBugTaskView(TestCaseWithFactory):
         browser = self.getUserBrowser(canonical_url(bug), bug.owner)
         self.assertIn(
             'href="/foobar/+bugs?field.tag=depends-on%2B987"',
-            browser.contents)
+            six.ensure_text(browser.contents))
 
     def test_information_type(self):
         owner = self.factory.makePerson()
@@ -329,7 +331,7 @@ class TestBugTaskView(TestCaseWithFactory):
             bug.markAsDuplicate(inactive_bug)
         removeSecurityProxy(inactive_project).active = False
         browser = self.getUserBrowser(canonical_url(bug))
-        contents = browser.contents
+        contents = six.ensure_text(browser.contents)
         self.assertIn(
             "This bug report is a duplicate of a bug on an inactive project.",
             contents)
@@ -344,7 +346,8 @@ class TestBugTaskView(TestCaseWithFactory):
         # portlet is hidden.
         bug = self.factory.makeBug()
         browser = self.getUserBrowser(canonical_url(bug))
-        self.assertNotIn('Related blueprints', browser.contents)
+        contents = six.ensure_text(browser.contents)
+        self.assertNotIn('Related blueprints', contents)
 
     def test_related_blueprints_is_shown(self):
         # When a bug has specifications linked, the Related blueprints portlet
@@ -354,8 +357,9 @@ class TestBugTaskView(TestCaseWithFactory):
         with person_logged_in(spec.owner):
             spec.linkBug(bug)
         browser = self.getUserBrowser(canonical_url(bug))
-        self.assertIn('Related blueprints', browser.contents)
-        self.assertIn('My brilliant spec', browser.contents)
+        contents = six.ensure_text(browser.contents)
+        self.assertIn('Related blueprints', contents)
+        self.assertIn('My brilliant spec', contents)
 
 
 class TestBugTasksNominationsView(TestCaseWithFactory):
@@ -1778,8 +1782,8 @@ class TestCommentCollapseVisibility(TestCaseWithFactory):
         bug = self.makeBugWithComments(20)
         url = canonical_url(bug.default_bugtask)
         browser = self.getUserBrowser(url=url)
-        contents = browser.contents
-        self.assertTrue("10 comments hidden" in contents)
+        contents = six.ensure_text(browser.contents)
+        self.assertIn("10 comments hidden", contents)
         self.assertEqual(1, contents.count('comments hidden'))
 
     def test_comments_hidden_message_truncation_and_hidden(self):
@@ -1791,9 +1795,9 @@ class TestCommentCollapseVisibility(TestCaseWithFactory):
         removeSecurityProxy(comments[-5]).visible = False
 
         browser = self.getUserBrowser(url=url)
-        contents = browser.contents
-        self.assertTrue("10 comments hidden" in browser.contents)
-        self.assertTrue("1 comments hidden" in browser.contents)
+        contents = six.ensure_text(browser.contents)
+        self.assertIn("10 comments hidden", contents)
+        self.assertIn("1 comments hidden", contents)
         self.assertEqual(2, contents.count('comments hidden'))
 
     def test_comments_hidden_message_truncation_and_hidden_out_of_order(self):
@@ -1813,9 +1817,9 @@ class TestCommentCollapseVisibility(TestCaseWithFactory):
         transaction.commit()
 
         browser = self.getUserBrowser(url=url)
-        contents = browser.contents
-        self.assertTrue("10 comments hidden" in browser.contents)
-        self.assertTrue("1 comments hidden" in browser.contents)
+        contents = six.ensure_text(browser.contents)
+        self.assertIn("10 comments hidden", contents)
+        self.assertIn("1 comments hidden", contents)
         self.assertEqual(2, contents.count('comments hidden'))
 
 
diff --git a/lib/lp/code/browser/widgets/tests/test_gitrepositorytargetwidget.py b/lib/lp/code/browser/widgets/tests/test_gitrepositorytargetwidget.py
index 906d33d..ebe6e9a 100644
--- a/lib/lp/code/browser/widgets/tests/test_gitrepositorytargetwidget.py
+++ b/lib/lp/code/browser/widgets/tests/test_gitrepositorytargetwidget.py
@@ -1,6 +1,8 @@
-# Copyright 2015-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import re
diff --git a/lib/lp/soyuz/model/binaryandsourcepackagename.py b/lib/lp/soyuz/model/binaryandsourcepackagename.py
index 91d1676..f5638d7 100644
--- a/lib/lp/soyuz/model/binaryandsourcepackagename.py
+++ b/lib/lp/soyuz/model/binaryandsourcepackagename.py
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -7,29 +7,26 @@ __all__ = [
     'BinaryAndSourcePackageNameVocabulary',
 ]
 
-from sqlobject import StringCol
+from storm.locals import Unicode
 from zope.interface import implementer
 from zope.schema.vocabulary import SimpleTerm
 
-from lp.services.database.sqlbase import SQLBase
+from lp.services.database.stormbase import StormBase
 from lp.services.webapp.vocabulary import (
     BatchedCountableIterator,
-    NamedSQLObjectHugeVocabulary,
+    NamedStormHugeVocabulary,
     )
 from lp.soyuz.interfaces.binarypackagename import IBinaryAndSourcePackageName
 
 
 @implementer(IBinaryAndSourcePackageName)
-class BinaryAndSourcePackageName(SQLBase):
+class BinaryAndSourcePackageName(StormBase):
     """See IBinaryAndSourcePackageName"""
 
-    _table = 'BinaryAndSourcePackageNameView'
-    _idName = 'name'
-    _idType = unicode
-    _defaultOrder = 'name'
+    __storm_table__ = 'BinaryAndSourcePackageNameView'
+    __storm_order__ = 'name'
 
-    name = StringCol(dbName='name', notNull=True, unique=True,
-                     alternateID=True)
+    name = Unicode('name', primary=True)
 
 
 class BinaryAndSourcePackageNameIterator(BatchedCountableIterator):
@@ -44,7 +41,7 @@ class BinaryAndSourcePackageNameIterator(BatchedCountableIterator):
                 for obj in results]
 
 
-class BinaryAndSourcePackageNameVocabulary(NamedSQLObjectHugeVocabulary):
+class BinaryAndSourcePackageNameVocabulary(NamedStormHugeVocabulary):
     """A vocabulary for searching for binary and sourcepackage names.
 
     This is useful for, e.g., reporting a bug on a 'package' when a reporter
@@ -56,7 +53,7 @@ class BinaryAndSourcePackageNameVocabulary(NamedSQLObjectHugeVocabulary):
     """
     _table = BinaryAndSourcePackageName
     displayname = 'Select a Package'
-    _orderBy = 'name'
+    _order_by = 'name'
     iterator = BinaryAndSourcePackageNameIterator
 
     def getTermByToken(self, token):