← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:testfix into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:testfix into launchpad:master.

Commit message:
Fix test failures from MailingList and SignedCodeOfConduct Storm ports

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/387422
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:testfix into launchpad:master.
diff --git a/lib/lp/registry/browser/codeofconduct.py b/lib/lp/registry/browser/codeofconduct.py
index c0252c6..616a11e 100644
--- a/lib/lp/registry/browser/codeofconduct.py
+++ b/lib/lp/registry/browser/codeofconduct.py
@@ -236,8 +236,8 @@ class SignedCodeOfConductAdminView(LaunchpadView):
 
         # use utility to query on SignedCoCs
         sCoC_util = getUtility(ISignedCodeOfConductSet)
-        self.results = sCoC_util.searchByDisplayname(name,
-                                                     searchfor=searchfor)
+        self.results = list(
+            sCoC_util.searchByDisplayname(name, searchfor=searchfor))
 
         return True
 
diff --git a/lib/lp/registry/doc/standing.txt b/lib/lp/registry/doc/standing.txt
index fa3df52..7e0b0f3 100644
--- a/lib/lp/registry/doc/standing.txt
+++ b/lib/lp/registry/doc/standing.txt
@@ -33,7 +33,7 @@ are not a member of, their message gets held for moderator approval.
     >>> from email.utils import formatdate
     >>> from lp.registry.interfaces.mailinglist import IMailingListSet
     >>> def post_message(from_address, to_team_name):
-    ...     message = getUtility(IMessageSet).fromEmail("""\
+    ...     message = getUtility(IMessageSet).fromEmail(("""\
     ... From: %s
     ... To: %s@xxxxxxxxxxxxxxxxxxxx
     ... Subject: Something to think about
@@ -41,7 +41,8 @@ are not a member of, their message gets held for moderator approval.
     ... Date: %s
     ...
     ... Point of order!
-    ... """ % (from_address, to_team_name, next(message_ids), formatdate()))
+    ... """ % (from_address, to_team_name, next(message_ids),
+    ...        formatdate())).encode('UTF-8'))
     ...     mailing_list = getUtility(IMailingListSet).get(to_team_name)
     ...     held_message = mailing_list.holdMessage(message)
     ...     return held_message
@@ -75,7 +76,7 @@ are not a member of, their message gets held for moderator approval.
 After one approval, Robert's standing does not change.
 
     >>> foobar = person_set.getByName('name16')
-    >>> message = lifeless_post('test-one')
+    >>> message = lifeless_post(u'test-one')
     >>> message.approve(foobar)
     >>> script.main()
     >>> lifeless.personal_standing
@@ -84,13 +85,13 @@ After one approval, Robert's standing does not change.
 Even after three approvals, if the message was posted to the same list,
 Robert's personal standing does not change.
 
-    >>> message = lifeless_post('test-one')
+    >>> message = lifeless_post(u'test-one')
     >>> message.approve(foobar)
     >>> script.main()
     >>> lifeless.personal_standing
     <DBItem PersonalStanding.UNKNOWN...>
 
-    >>> message = lifeless_post('test-one')
+    >>> message = lifeless_post(u'test-one')
     >>> message.approve(foobar)
     >>> script.main()
     >>> lifeless.personal_standing
@@ -103,7 +104,7 @@ his personal standing can be updated.
     >>> team_three, list_three = mailinglists_helper.new_team(
     ...     'test-three', True)
 
-    >>> message = lifeless_post('test-two')
+    >>> message = lifeless_post(u'test-two')
     >>> message.approve(foobar)
     >>> script.main()
     >>> lifeless.personal_standing
@@ -111,13 +112,13 @@ his personal standing can be updated.
 
 Rejected and discarded messages don't count.
 
-    >>> message = lifeless_post('test-three')
+    >>> message = lifeless_post(u'test-three')
     >>> message.reject(foobar)
     >>> script.main()
     >>> lifeless.personal_standing
     <DBItem PersonalStanding.UNKNOWN...>
 
-    >>> message = lifeless_post('test-three')
+    >>> message = lifeless_post(u'test-three')
     >>> message.discard(foobar)
     >>> script.main()
     >>> lifeless.personal_standing
@@ -125,10 +126,10 @@ Rejected and discarded messages don't count.
 
 Neither do approved messages from someone else.
 
-    >>> message = post_message('carlos@xxxxxxxxxxxxx', 'test-two')
+    >>> message = post_message('carlos@xxxxxxxxxxxxx', u'test-two')
     >>> message.approve(foobar)
 
-    >>> message = post_message('carlos@xxxxxxxxxxxxx', 'test-three')
+    >>> message = post_message('carlos@xxxxxxxxxxxxx', u'test-three')
     >>> message.approve(foobar)
 
     >>> script.main()
@@ -142,7 +143,7 @@ Neither do approved messages from someone else.
 Robert's next message goes to a third mailing list, and this gets
 approved.  As a result, his personal standing gets updated.
 
-    >>> message = lifeless_post('test-three')
+    >>> message = lifeless_post(u'test-three')
     >>> message.approve(foobar)
     >>> script.main()
     >>> lifeless.personal_standing
@@ -154,20 +155,20 @@ approved.  As a result, his personal standing gets updated.
 Along comes Mark who also sends three messages to three different lists.  His
 personal standing gets updated to Good also.
 
-    >>> message = post_message('mark@xxxxxxxxxxx', 'test-one')
+    >>> message = post_message('mark@xxxxxxxxxxx', u'test-one')
     >>> message.approve(foobar)
     >>> script.main()
     >>> mark = person_set.getByName('mark')
     >>> mark.personal_standing
     <DBItem PersonalStanding.UNKNOWN...>
 
-    >>> message = post_message('mark@xxxxxxxxxxx', 'test-two')
+    >>> message = post_message('mark@xxxxxxxxxxx', u'test-two')
     >>> message.approve(foobar)
     >>> script.main()
     >>> mark.personal_standing
     <DBItem PersonalStanding.UNKNOWN...>
 
-    >>> message = post_message('mark@xxxxxxxxxxx', 'test-three')
+    >>> message = post_message('mark@xxxxxxxxxxx', u'test-three')
     >>> message.approve(foobar)
     >>> script.main()
     >>> mark.personal_standing
@@ -254,7 +255,7 @@ standing untouched.
 Carlos sends one more message, which also gets approved.  Now the
 update-standing script bumps his standing to Good too.
 
-    >>> message = post_message('carlos@xxxxxxxxxxxxx', 'test-one')
+    >>> message = post_message('carlos@xxxxxxxxxxxxx', u'test-one')
     >>> message.approve(foobar)
     >>> LaunchpadZopelessLayer.txn.commit()
     >>> mailinglists_helper.mailman.act()
diff --git a/lib/lp/registry/doc/vocabularies.txt b/lib/lp/registry/doc/vocabularies.txt
index 551334b..307eaa1 100644
--- a/lib/lp/registry/doc/vocabularies.txt
+++ b/lib/lp/registry/doc/vocabularies.txt
@@ -105,13 +105,13 @@ a search term of None, all active lists are returned.
 If given, the search term matches the team name.
 
     >>> sorted(mailing_list.team.displayname
-    ...        for mailing_list in list_vocabulary.search('player'))
+    ...        for mailing_list in list_vocabulary.search(u'player'))
     [u'Bass Players', u'Guitar Players']
 
 The IHugeVocabulary interface also requires a search method that returns
 a CountableIterator.
 
-    >>> iter = list_vocabulary.searchForTerms('player')
+    >>> iter = list_vocabulary.searchForTerms(u'player')
     >>> from lp.services.webapp.vocabulary import CountableIterator
     >>> isinstance(iter, CountableIterator)
     True
@@ -186,10 +186,10 @@ Non-ACTIVE mailing lists are also not contained in the vocabulary.
 
 Sometimes, the vocabulary search doesn't return any active lists.
 
-    >>> list(list_vocabulary.search('flautists'))
+    >>> list(list_vocabulary.search(u'flautists'))
     []
 
-    >>> list(list_vocabulary.search('cellists'))
+    >>> list(list_vocabulary.search(u'cellists'))
     []
 
 
@@ -1118,13 +1118,13 @@ They can be looked up by their aliases too.
     >>> vocab.getTermByToken('iceweasel').token
     'firefox'
 
-    >>> [term.token for term in vocab.searchForTerms(query='iceweasel')]
+    >>> [term.token for term in vocab.searchForTerms(query=u'iceweasel')]
     ['firefox']
 
 Aliases are not among the terms when their name does not match the
 token/name.
 
-    >>> [term.token for term in vocab.searchForTerms(query='ubuntu')]
+    >>> [term.token for term in vocab.searchForTerms(query=u'ubuntu')]
     ['ubuntu', 'kubuntu', 'ubuntutest']
 
     >>> vocab.getTermByToken('ubuntu').token
@@ -1187,7 +1187,7 @@ They can be looked up by their aliases too.
     >>> vocab.getTermByToken('ubantoo').token
     'ubuntu'
 
-    >>> [term.token for term in vocab.searchForTerms(query='ubantoo')]
+    >>> [term.token for term in vocab.searchForTerms(query=u'ubantoo')]
     ['ubuntu']
 
 Inactive projects and project groups are not available.
diff --git a/lib/lp/registry/model/codeofconduct.py b/lib/lp/registry/model/codeofconduct.py
index 7f4d909..cc484b9 100644
--- a/lib/lp/registry/model/codeofconduct.py
+++ b/lib/lp/registry/model/codeofconduct.py
@@ -254,7 +254,7 @@ class SignedCodeOfConductSet:
 
     def __getitem__(self, id):
         """Get a Signed CoC Entry."""
-        return IStore(SignedCodeOfConduct).get(SignedCodeOfConduct, id)
+        return IStore(SignedCodeOfConduct).get(SignedCodeOfConduct, int(id))
 
     def __iter__(self):
         """Iterate through the Signed CoC."""
diff --git a/lib/lp/registry/templates/person-codesofconduct.pt b/lib/lp/registry/templates/person-codesofconduct.pt
index 39af11c..76da2f7 100644
--- a/lib/lp/registry/templates/person-codesofconduct.pt
+++ b/lib/lp/registry/templates/person-codesofconduct.pt
@@ -12,12 +12,12 @@
     sign as commitments to the principles of collaboration, tolerance and
     open communication that drive the open source community.</p>
 
-    <p tal:condition="not: context/signedcocs">
+    <p tal:condition="context/signedcocs/is_empty">
       <tal:name replace="context/fmt:displayname"/> has never signed a code
       of conduct.
     </p>
 
-    <div tal:condition="context/activesignatures">
+    <div tal:condition="not: context/activesignatures/is_empty">
       <form name="coc" action="" method="post">
         <h2>Active signatures</h2>
         <p>If you change your mind about agreeing to a code of conduct,
@@ -52,7 +52,7 @@
       </form>
     </div>
 
-    <div tal:condition="context/inactivesignatures">
+    <div tal:condition="not: context/inactivesignatures/is_empty">
       <h2>Inactive signatures</h2>
       <p>
         Once <dfn>Inactive</dfn>, a signature can only be reactivated by a
diff --git a/lib/lp/registry/tests/test_personset.py b/lib/lp/registry/tests/test_personset.py
index 27baf69..02f8143 100644
--- a/lib/lp/registry/tests/test_personset.py
+++ b/lib/lp/registry/tests/test_personset.py
@@ -191,8 +191,9 @@ class TestPersonSet(TestCaseWithFactory):
     def test_getPrecachedPersonsFromIDs_is_ubuntu_coc_signer(self):
         # getPrecachedPersonsFromIDs() sets is_ubuntu_coc_signer
         # correctly.
-        person_ids = [self.factory.makePerson().id for i in range(3)]
-        SignedCodeOfConduct(owner=person_ids[0], active=True)
+        persons = [self.factory.makePerson() for i in range(3)]
+        person_ids = [person.id for person in persons]
+        SignedCodeOfConduct(owner=persons[0], active=True)
         flush_database_caches()
 
         persons = list(
diff --git a/lib/lp/registry/vocabularies.py b/lib/lp/registry/vocabularies.py
index bd259ea..d7ef98d 100644
--- a/lib/lp/registry/vocabularies.py
+++ b/lib/lp/registry/vocabularies.py
@@ -67,6 +67,7 @@ from operator import attrgetter
 import re
 
 from lazr.restful.interfaces import IReference
+import six
 from sqlobject import (
     AND,
     CONTAINSSTRING,
@@ -1024,7 +1025,7 @@ class ActiveMailingListVocabulary(FilteredVocabularyBase):
     def getTermByToken(self, token):
         """See `IVocabularyTokenized`."""
         # token should be the team name as a string.
-        team_list = getUtility(IMailingListSet).get(token)
+        team_list = getUtility(IMailingListSet).get(six.ensure_text(token))
         if team_list is None:
             raise LookupError(token)
         return self.getTerm(team_list)
@@ -1043,6 +1044,7 @@ class ActiveMailingListVocabulary(FilteredVocabularyBase):
         # The mailing list name, such as it has one, is really the name of the
         # team to which it is linked.
         return IStore(MailingList).find(
+            MailingList,
             MailingList.team == Person.id,
             fti_search(Person, text),
             Person.teamowner != None,