def test_non_owner_unauthorised(self):
     # Only team owners can reassign team ownership.
     team = self.factory.makeTeam()
     any_person = self.factory.makePerson()
     reassign_url = canonical_url(team, view_name='+reassign')
     browser = setupBrowserForUser(any_person)
     self.assertRaises(Unauthorized, browser.open, reassign_url)
 def test_non_owner_unauthorised(self):
     # Only team owners can reassign team ownership.
     team = self.factory.makeTeam()
     any_person = self.factory.makePerson()
     reassign_url = canonical_url(team, view_name='+reassign')
     browser = setupBrowserForUser(any_person)
     self.assertRaises(Unauthorized, browser.open, reassign_url)
Exemplo n.º 3
0
 def test_sharing_menu(self):
     url = canonical_url(self.pillar)
     sharing_url = canonical_url(self.pillar, view_name='+sharing')
     browser = setupBrowserForUser(user=self.driver)
     browser.open(url)
     soup = BeautifulSoup(browser.contents)
     sharing_menu = soup.find('a', {'href': sharing_url})
     self.assertIsNotNone(sharing_menu)
 def _getBrowser(self, user=None):
     if user is None:
         browser = setupBrowser()
         logout()
         return browser
     else:
         login_person(user)
     return setupBrowserForUser(user=user)
 def test_unauthorized_subscriber_for_plus_packages(self):
     with person_logged_in(self.owner):
         self.archive.newSubscription(self.subscriber,
                                      registrant=self.archive.owner)
     with person_logged_in(self.subscriber):
         url = urljoin(canonical_url(self.archive), '+packages')
     browser = setupBrowserForUser(self.subscriber)
     self.assertRaises(Unauthorized, browser.open, url)
 def _getBrowser(self, user=None):
     if user is None:
         browser = setupBrowser()
         logout()
         return browser
     else:
         login_person(user)
     return setupBrowserForUser(user=user)
 def test_unauthorized_subscriber_for_plus_packages(self):
     with person_logged_in(self.owner):
         self.archive.newSubscription(
             self.subscriber, registrant=self.archive.owner)
     with person_logged_in(self.subscriber):
         url = urljoin(canonical_url(self.archive), '+packages')
     browser = setupBrowserForUser(self.subscriber)
     self.assertRaises(Unauthorized, browser.open, url)
Exemplo n.º 8
0
 def test_unauthorized_subscriber_for_plus_packages(self):
     self.useFixture(FakeLogger())
     with person_logged_in(self.owner):
         self.archive.newSubscription(self.subscriber,
                                      registrant=self.archive.owner)
     with person_logged_in(self.subscriber):
         url = canonical_url(self.archive) + '/+packages'
     browser = setupBrowserForUser(self.subscriber)
     self.assertRaises(Unauthorized, browser.open, url)
 def test_view_navigation_links(self):
     # Check the navigation links get get to the change owner page.
     owner = self.factory.makePerson()
     team = self.factory.makeTeam(owner=owner)
     edit_url = canonical_url(team, view_name='+edit')
     reassign_url = canonical_url(team, view_name='+reassign')
     browser = setupBrowserForUser(owner)
     browser.open(edit_url)
     browser.getLink('Change owner').click()
     self.assertEqual(reassign_url, browser.url)
 def test_view_navigation_links(self):
     # Check the navigation links get get to the change owner page.
     owner = self.factory.makePerson()
     team = self.factory.makeTeam(owner=owner)
     edit_url = canonical_url(team, view_name='+edit')
     reassign_url = canonical_url(team, view_name='+reassign')
     browser = setupBrowserForUser(owner)
     browser.open(edit_url)
     browser.getLink('Change owner').click()
     self.assertEqual(reassign_url, browser.url)
Exemplo n.º 11
0
 def test_traverse_view_private_team_archive_subscriber(self):
     # A subscriber can traverse and view the archive.
     with person_logged_in(self.owner):
         self.archive.newSubscription(self.subscriber,
                                      registrant=self.archive.owner)
     with person_logged_in(self.subscriber):
         url = canonical_url(self.archive)
     browser = setupBrowserForUser(self.subscriber)
     browser.open(url)
     content = find_tag_by_id(browser.contents, 'document')
     self.assertIsNotNone(find_tag_by_id(content, 'ppa-install'))
 def test_traverse_view_private_team_archive_subscriber(self):
     # A subscriber can traverse and view the archive.
     with person_logged_in(self.owner):
         self.archive.newSubscription(
             self.subscriber, registrant=self.archive.owner)
     with person_logged_in(self.subscriber):
         url = canonical_url(self.archive)
     browser = setupBrowserForUser(self.subscriber)
     browser.open(url)
     content = find_tag_by_id(browser.contents, 'document')
     self.assertIsNotNone(find_tag_by_id(content, 'ppa-install'))
Exemplo n.º 13
0
 def test_view_contents(self):
     # Distributions are rendered with the correct text.
     url = canonical_url(self.pillar, view_name='+sharing')
     browser = setupBrowserForUser(user=self.driver)
     browser.open(url)
     soup = BeautifulSoup(browser.contents)
     commercial_text = soup.find('p', {'id': 'commercial-project-text'})
     non_commercial_text = soup.find(
         'p', {'id': 'non-commercial-project-text'})
     self.assertIsNone(commercial_text)
     self.assertIsNone(non_commercial_text)
Exemplo n.º 14
0
 def test_view_contents_commercial_project(self):
     # Commercial projects are rendered with the correct text.
     self.factory.makeCommercialSubscription(self.pillar)
     url = canonical_url(self.pillar, view_name='+sharing')
     browser = setupBrowserForUser(user=self.driver)
     browser.open(url)
     soup = BeautifulSoup(browser.contents)
     commercial_text = soup.find('p', {'id': 'commercial-project-text'})
     non_commercial_text = soup.find(
         'p', {'id': 'non-commercial-project-text'})
     self.assertIsNotNone(commercial_text)
     self.assertIsNone(non_commercial_text)
Exemplo n.º 15
0
 def match(self, context):
     # circular dependencies.
     from lp.testing.pages import setupBrowserForUser
     with person_logged_in(self.user):
         context_url = canonical_url(context,
                                     view_name=self.view_name,
                                     **self.options)
     browser = setupBrowserForUser(self.user)
     flush_database_caches()
     with RequestTimelineCollector() as collector:
         browser.open(context_url)
     counter = HasQueryCount(LessThan(self.query_limit))
     # When bug 724691 is fixed, this can become an AnnotateMismatch to
     # describe the object being rendered.
     return counter.match(collector)
Exemplo n.º 16
0
 def run_sharing_message_test(self, pillar, owner, public):
     with person_logged_in(owner):
         public_pillar_sharing_info = (
             "Everyone can see %s's public information."
             % pillar.displayname)
         url = canonical_url(pillar, view_name='+sharing')
     browser = setupBrowserForUser(user=owner)
     browser.open(url)
     if public:
         self.assertTrue(public_pillar_sharing_info in browser.contents)
         self.assertFalse(
             "This project has no public information." in browser.contents)
     else:
         self.assertFalse(public_pillar_sharing_info in browser.contents)
         self.assertTrue(
             "This project has no public information." in browser.contents)
Exemplo n.º 17
0
 def match(self, context):
     # circular dependencies.
     from lp.testing.pages import setupBrowserForUser
     with person_logged_in(self.user):
         context_url = canonical_url(
             context, view_name=self.view_name, **self.options)
     browser = setupBrowserForUser(self.user)
     flush_database_caches()
     collector = QueryCollector()
     collector.register()
     try:
         browser.open(context_url)
         counter = HasQueryCount(LessThan(self.query_limit))
         # When bug 724691 is fixed, this can become an AnnotateMismatch to
         # describe the object being rendered.
         return counter.match(collector)
     finally:
         # Unregister now in case this method is called multiple
         # times in a single test.
         collector.unregister()
 def makeNonRedirectingBrowser(self, url, user=None):
     browser = setupBrowserForUser(user) if user else setupBrowser()
     browser.mech_browser.set_handle_equiv(False)
     browser.open(url)
     return browser
Exemplo n.º 19
0
 def makeNonRedirectingBrowser(self, url, user=None):
     browser = setupBrowserForUser(user) if user else setupBrowser()
     browser.mech_browser.set_handle_equiv(False)
     browser.open(url)
     return browser