def test_display_no_message(self): # A notification is not added if there is no message to show. product, user = self.make_product_user([License.GNU_GPL_V2]) notification = LicenseNotification(product) result = notification.display() self.assertEqual('', notification.getCommercialUseMessage()) self.assertIs(False, result)
def test_display_no_request(self): # If there is no request, there is no reason to show a message in # the browser. product, user = self.make_product_user([License.GNU_GPL_V2]) # Using the proxied product leads to an exeception when # notification.display() below is called because the permission # checks product require an interaction. notification = LicenseNotification(removeSecurityProxy(product)) logout() result = notification.display() self.assertIs(False, result)
def test_display_escapee_user_data(self): # A notification is added if there is a message to show. product, user = self.make_product_user([License.OTHER_PROPRIETARY]) product.display_name = '<b>Look</b>' notification = LicenseNotification(product) result = notification.display() self.assertIs(True, result) request = get_current_browser_request() self.assertEqual(1, len(request.response.notifications)) self.assertIn('<b>Look</b>', request.response.notifications[0].message)
def test_display_escapee_user_data(self): # A notification is added if there is a message to show. product, user = self.make_product_user([License.OTHER_PROPRIETARY]) product.displayname = '<b>Look</b>' notification = LicenseNotification(product) result = notification.display() self.assertIs(True, result) request = get_current_browser_request() self.assertEqual(1, len(request.response.notifications)) self.assertIn( '<b>Look</b>', request.response.notifications[0].message)
def test_display_has_message(self): # A notification is added if there is a message to show. product, user = self.make_product_user([License.OTHER_PROPRIETARY]) notification = LicenseNotification(product) result = notification.display() message = notification.getCommercialUseMessage() self.assertIs(True, result) request = get_current_browser_request() self.assertEqual(1, len(request.response.notifications)) self.assertIn( html_escape(message), request.response.notifications[0].message) self.assertIn( '<a href="https://help.launchpad.net/CommercialHosting">', request.response.notifications[0].message)