def test_getCommercialUseMessage_with_complimentary_cs(self): product, user = self.make_product_user([License.OTHER_PROPRIETARY]) notification = LicenseNotification(product) message = ( "Ball's complimentary commercial subscription expires on %s." % product.commercial_subscription.date_expires.date().isoformat()) self.assertEqual(message, notification.getCommercialUseMessage())
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_getCommercialUseMessage_with_commercial_subscription(self): product, user = self.make_product_user([License.MIT]) self.factory.makeCommercialSubscription(product) product.licenses = [License.MIT, License.OTHER_PROPRIETARY] notification = LicenseNotification(product) message = ( "Ball's commercial subscription expires on %s." % product.commercial_subscription.date_expires.date().isoformat()) self.assertEqual(message, notification.getCommercialUseMessage())
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)
def test_getCommercialUseMessage_without_commercial_subscription(self): product, user = self.make_product_user([License.MIT]) notification = LicenseNotification(product) self.assertEqual('', notification.getCommercialUseMessage())