Ejemplo n.º 1
0
 def assertRender(self, dt_content=None, dd_content=None):
     root = html.fromstring(self.view.render())
     if dt_content is not None:
         self.assertEqual(
             dt_content,
             normalize_whitespace(root.find("dt").text_content()))
     if dd_content is not None:
         self.assertEqual(
             dd_content,
             normalize_whitespace(root.find("dd").text_content()))
 def assertRender(self, dt_content=None, dd_content=None):
     root = html.fromstring(self.view.render())
     if dt_content is not None:
         self.assertEqual(
             dt_content, normalize_whitespace(
                 root.find("dt").text_content()))
     if dd_content is not None:
         self.assertEqual(
             dd_content, normalize_whitespace(
                 root.find("dd").text_content()))
 def test_no_branches_gets_message_not_listing(self):
     # If there are no product branches on the project's products, then
     # the view shows the no code hosting message instead of a listing.
     self.factory.makeProduct(project=self.project)
     view = create_initialized_view(
         self.project, name='+branches', rootsite='code')
     displayname = self.project.displayname
     expected_text = normalize_whitespace(
         ("Launchpad does not know where any of %s's "
          "projects host their code." % displayname))
     no_branch_div = find_tag_by_id(view(), "no-branchtable")
     text = normalize_whitespace(extract_text(no_branch_div))
     self.assertEqual(expected_text, text)
 def test_no_branches_gets_message_not_listing(self):
     # If there are no product branches on the project's products, then
     # the view shows the no code hosting message instead of a listing.
     self.factory.makeProduct(project=self.project)
     view = create_initialized_view(self.project,
                                    name='+branches',
                                    rootsite='code')
     displayname = self.project.displayname
     expected_text = normalize_whitespace(
         ("Launchpad does not know where any of %s's "
          "projects host their code." % displayname))
     no_branch_div = find_tag_by_id(view(), "no-branchtable")
     text = normalize_whitespace(extract_text(no_branch_div))
     self.assertEqual(expected_text, text)
 def test_announcement_info(self):
     product = self.factory.makeProduct(displayname=u"Foo")
     announcer = self.factory.makePerson(displayname=u"Bar Baz")
     announcement = product.announce(announcer, "Hello World")
     view = create_initialized_view(announcement, "+index")
     root = html.fromstring(view())
     [reg_para] = root.cssselect("p.registered")
     self.assertEqual(
         "Written for Foo by Bar Baz",
         normalize_whitespace(reg_para.text_content()))
Ejemplo n.º 6
0
 def test_execute_bug_cannot_add_task(self):
     # Test that attempts to invalidly add a new bug task results in the
     # expected error message.
     product = self.factory.makeProduct(
         bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
     bug = self.factory.makeBug(
         target=product, information_type=InformationType.PROPRIETARY)
     self.factory.makeProduct(
         name='fnord', bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
     login_celebrity('admin')
     login_person(bug.owner)
     command = AffectsEmailCommand('affects', ['fnord'])
     error = self.assertRaises(EmailProcessingError, command.execute, bug,
                               None)
     reason = ("This proprietary bug already affects %s. "
               "Proprietary bugs cannot affect multiple projects." %
               product.displayname)
     self.assertEqual(
         normalize_whitespace(
             "Bug %s cannot be marked as affecting fnord. %s" %
             (bug.id, reason)), normalize_whitespace(str(error)))
 def test_announcement_info_with_publication_date(self):
     product = self.factory.makeProduct(displayname=u"Foo")
     announcer = self.factory.makePerson(displayname=u"Bar Baz")
     announced = datetime(2007, 01, 12, tzinfo=utc)
     announcement = product.announce(
         announcer, "Hello World", publication_date=announced)
     view = create_initialized_view(announcement, "+index")
     root = html.fromstring(view())
     [reg_para] = root.cssselect("p.registered")
     self.assertEqual(
         "Written for Foo by Bar Baz on 2007-01-12",
         normalize_whitespace(reg_para.text_content()))
Ejemplo n.º 8
0
 def test_execute_bug_cannot_add_task(self):
     # Test that attempts to invalidly add a new bug task results in the
     # expected error message.
     product = self.factory.makeProduct(
         bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
     bug = self.factory.makeBug(
         target=product, information_type=InformationType.PROPRIETARY)
     self.factory.makeProduct(
         name='fnord', bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
     login_celebrity('admin')
     login_person(bug.owner)
     command = AffectsEmailCommand('affects', ['fnord'])
     error = self.assertRaises(
         EmailProcessingError, command.execute, bug, None)
     reason = ("This proprietary bug already affects %s. "
                 "Proprietary bugs cannot affect multiple projects." %
                 product.displayname)
     self.assertEqual(
         normalize_whitespace(
             "Bug %s cannot be marked as affecting fnord. %s"
                 % (bug.id, reason)),
         normalize_whitespace(str(error)))
Ejemplo n.º 9
0
 def test_no_sharing_message(self):
     # If there is no sharing between pillar and person, a suitable message
     # is displayed.
     # We have to do some fun url hacking to force the traversal a user
     # encounters.
     pillarperson = PillarPerson(
         self.pillar, self.factory.makePerson())
     url = 'http://launchpad.dev/%s/+sharing/%s' % (
         pillarperson.pillar.name, pillarperson.person.name)
     browser = self.getUserBrowser(user=self.owner, url=url)
     self.assertIn(
         'There are no shared bugs, Bazaar branches, Git repositories, or '
         'blueprints.', normalize_whitespace(browser.contents))
Ejemplo n.º 10
0
 def match(self, observed):
     if isinstance(observed, (str, unicode)):
         observed = normalize_whitespace(observed)
     return super(EqualsIgnoringWhitespace, self).match(observed)
Ejemplo n.º 11
0
 def __init__(self, expected):
     if isinstance(expected, (str, unicode)):
         expected = normalize_whitespace(expected)
     super(EqualsIgnoringWhitespace, self).__init__(expected)
Ejemplo n.º 12
0
 def match(self, observed):
     if isinstance(observed, (str, unicode)):
         observed = normalize_whitespace(observed)
     return super(EqualsIgnoringWhitespace, self).match(observed)
Ejemplo n.º 13
0
 def __init__(self, expected):
     if isinstance(expected, (str, unicode)):
         expected = normalize_whitespace(expected)
     super(EqualsIgnoringWhitespace, self).__init__(expected)