Example #1
0
 def test_any_active(self):
     assert not InappConfig.any_active(self.app)
     InappConfig.objects.create(addon=self.app,
                                status=amo.INAPP_STATUS_ACTIVE,
                                private_key='asd-1', public_key='asd-1')
     assert InappConfig.any_active(self.app)
     self.assertRaises(ValueError, InappConfig.objects.create,
                       addon=self.app, status=amo.INAPP_STATUS_ACTIVE,
                       private_key='asd-2', public_key='asd-2')
Example #2
0
 def test_retry_public_keygen_until_unique(self, fake_filter):
     (fake_filter.expects_call().returns_fake().expects('count').returns(1)
                                               .next_call().returns(1)
                                               .next_call().returns(0))
     assert InappConfig.generate_public_key(max_tries=5)
Example #3
0
 def test_exhaust_public_keygen_attempts(self, fake_filter):
     fake_filter.expects_call().returns_fake().expects('count').returns(1)
     InappConfig.generate_public_key(max_tries=5)
Example #4
0
 def test_generate_private_key(self):
     key = InappConfig.generate_private_key()
     assert key
Example #5
0
 def test_generate_public_key(self):
     key = InappConfig.generate_public_key()
     assert key
Example #6
0
 def test_any_active_excludes_config_under_edit(self):
     c = InappConfig.objects.create(addon=self.app,
                                    status=amo.INAPP_STATUS_ACTIVE,
                                    private_key='asd-1', public_key='asd-1')
     assert not InappConfig.any_active(self.app, exclude_config=c.pk)
     c.save()  # no exception