def test_deactivateCommercialFeatures_open_source(self): # When the project is open source, the product's commercial features # are deactivated and the commercial subscription is deleted. product, reviewer = self.make_notification_data(licenses=[License.MIT]) public_branch = self.factory.makeBranch( owner=product.owner, product=product) private_branch = self.factory.makeBranch( owner=product.owner, product=product, information_type=InformationType.USERDATA) with person_logged_in(product.owner): public_series = product.development_focus public_series.branch = public_branch private_series = product.newSeries( product.owner, 'special', 'testing', branch=private_branch) # Verify that branchless series do not raise an error. product.newSeries(product.owner, 'unused', 'no branch') self.expire_commercial_subscription(product) job = CommercialExpiredJob.create(product, reviewer) job._deactivateCommercialFeatures() clear_property_cache(product) self.assertTrue(product.active) self.assertEqual( BranchSharingPolicy.FORBIDDEN, product.branch_sharing_policy) self.assertEqual( BugSharingPolicy.FORBIDDEN, product.bug_sharing_policy) self.assertEqual(public_branch, public_series.branch) self.assertIs(None, private_series.branch) self.assertIs(None, product.commercial_subscription)
def test_email_template_name_proprietary(self): # The state of the product's licence defines the email_template_name. product, reviewer = self.make_notification_data( licenses=[License.OTHER_PROPRIETARY]) job = CommercialExpiredJob.create(product, reviewer) self.assertEqual('product-commercial-subscription-expired-proprietary', job.email_template_name)
def test_email_template_name(self): # Redefine the inherited test to verify the open source licence case. # The state of the product's licence defines the email_template_name. product, reviewer = self.make_notification_data(licenses=[License.MIT]) job = CommercialExpiredJob.create(product, reviewer) self.assertEqual('product-commercial-subscription-expired-open-source', job.email_template_name)
def test_run_deactivation_performed(self): # An email is sent and the deactivation steps are performed. product, reviewer = self.make_notification_data( licenses=[License.OTHER_PROPRIETARY]) self.expire_commercial_subscription(product) job = CommercialExpiredJob.create(product, reviewer) job.run() self.assertIs(False, product.active)
def test_email_template_name_proprietary(self): # The state of the product's licence defines the email_template_name. product, reviewer = self.make_notification_data( licenses=[License.OTHER_PROPRIETARY]) job = CommercialExpiredJob.create(product, reviewer) self.assertEqual( 'product-commercial-subscription-expired-proprietary', job.email_template_name)
def test_email_template_name(self): # Redefine the inherited test to verify the open source licence case. # The state of the product's licence defines the email_template_name. product, reviewer = self.make_notification_data(licenses=[License.MIT]) job = CommercialExpiredJob.create(product, reviewer) self.assertEqual( 'product-commercial-subscription-expired-open-source', job.email_template_name)
def test_deactivateCommercialFeatures_proprietary(self): # When the project is proprietary, the product is deactivated. product, reviewer = self.make_notification_data( licenses=[License.OTHER_PROPRIETARY]) self.expire_commercial_subscription(product) job = CommercialExpiredJob.create(product, reviewer) job._deactivateCommercialFeatures() clear_property_cache(product) self.assertIs(False, product.active) self.assertIsNot(None, product.commercial_subscription)
def test_run_deactivation_aborted(self): # The deactivation steps and email are aborted if the commercial # subscription was renewed after the job was created. product, reviewer = self.make_notification_data( licenses=[License.OTHER_PROPRIETARY]) job = CommercialExpiredJob.create(product, reviewer) pop_notifications() job.run() notifications = pop_notifications() self.assertEqual(0, len(notifications)) self.assertIs(True, product.active)
def test_is_proprietary_proprietary(self): product, reviewer = self.make_notification_data( licenses=[License.OTHER_PROPRIETARY]) job = CommercialExpiredJob.create(product, reviewer) self.assertIs(True, job._is_proprietary)
def test_is_proprietary_open_source(self): product, reviewer = self.make_notification_data(licenses=[License.MIT]) job = CommercialExpiredJob.create(product, reviewer) self.assertIs(False, job._is_proprietary)