コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 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)
コード例 #9
0
 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)
コード例 #10
0
 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)
コード例 #11
0
 def test_get_expiration_dates(self):
     dates = CommercialExpiredJob._get_expiration_dates()
     earliest_date, latest_date, past_date = dates
     self.assertEqual(timedelta(days=3650), latest_date - earliest_date)
     self.assertEqual(timedelta(days=30), latest_date - past_date)