Esempio n. 1
0
 def test_none(self, which):
     self.assertFalse(
         can_i_use(
             ClientUser.user_from_object('test'),
             functionality=Functionality()
         )
     )
Esempio n. 2
0
 def test_roll_out_recall_false(self):
     context = WhichContext()
     context.functionality = Functionality(
         rollout_strategy=Functionality.DEFINED_BY_RELEASES)
     try:
         check_roll_out_recall(context=context)
     except NoAvailability:
         self.fail()
Esempio n. 3
0
class EnableExistingAvailability(TestCase):
    def setUp(self):
        self.company = Company(name='Testcompany')
        self.company.save()
        self.user = ClientUser.user_from_object('testuser')
        self.user.save()
        app = App(name='Test App', slug='test-app', company=self.company)
        app.save()
        self.functionality = Functionality(app=app, name='Test Func', slug='test-func',
                                           rollout_strategy=Functionality.DEFINED_BY_RELEASES)
        self.functionality.save()
        flavor = Flavor(name='Flav', slug='flav', functionality=self.functionality)
        flavor.save()
        self.availability = Availability(flavor=flavor, user=self.user)
        self.availability.save()
        self.release = Release(functionality=self.functionality, max_enabled_users=10)
        self.release.save()

    def test_already_enabled(self):
        context = WhichContext()
        context.availability = Availability(is_enabled=True)
        context.functionality = Functionality()
        context.functionality.availability = context.availability
        availability = enable_availability_by_user_count(context)
        self.assertEqual(availability, context.availability)

    def test_wrong_roll_out_strategy(self):
        context = WhichContext()
        context.availability = Availability(is_enabled=False)
        context.functionality = Functionality(rollout_strategy=Functionality.RECALL_FUNCTIONALITY)
        availability = enable_availability_by_user_count(context)
        self.assertIsNone(availability)

    def test_enable_with_users_to_spare(self):
        context = WhichContext()
        context.availability = self.availability
        context.functionality = self.functionality
        context.enabled_count = 5
        availability = enable_availability_by_user_count(context)
        self.assertEqual(availability, self.availability)
Esempio n. 4
0
class GetAvailability(TestCase):
    def setUp(self):
        self.company = Company(name='Testcompany')
        self.company.save()
        self.user = ClientUser.user_from_object('testuser')
        self.user.save()
        app = App(name='Test App', slug='test-app', company=self.company)
        app.save()
        self.functionality = Functionality(app=app, name='Test Func', slug='test-func')
        self.functionality.save()
        flavor = Flavor(name='Flav', slug='flav', functionality=self.functionality)
        flavor.save()
        self.availability = Availability(flavor=flavor, user=self.user)
        self.availability.save()

    def test_get_availability(self):
        context = WhichContext()
        context.client_user = self.user
        context.functionality = self.functionality
        get_availability(context)
        self.assertIsNotNone(context.availability)
        self.assertEqual(context.availability, self.availability)
Esempio n. 5
0
class AssertExistenceOfFlavors(TestCase):
    def test_with_flavors_present(self):
        company = Company(name='Testcompany')
        company.save()
        app = App(name='Test App', slug='test-app', company=company)
        app.save()
        self.functionality = Functionality(app=app, name='Test Func', slug='test-func',
                                           rollout_strategy=Functionality.DEFINED_BY_RELEASES)
        self.functionality.save()
        flavor = Flavor(name='Flav', slug='flav', functionality=self.functionality)
        flavor.save()

        context = WhichContext()
        context.functionality = self.functionality
        self.assertIsNone(assert_existence_of_flavors(context))

    def test_with_no_flavors_present(self):
        context = WhichContext()
        context.functionality = Functionality()

        from core.functionality import NoAvailability
        with self.assertRaises(NoAvailability):
            assert_existence_of_flavors(context)
Esempio n. 6
0
 def test_wrong_roll_out_strategy(self):
     context = WhichContext()
     context.availability = Availability(is_enabled=False)
     context.functionality = Functionality(rollout_strategy=Functionality.RECALL_FUNCTIONALITY)
     availability = enable_availability_by_user_count(context)
     self.assertIsNone(availability)
Esempio n. 7
0
 def test_roll_out_recall_true(self):
     context = WhichContext()
     context.functionality = Functionality(
         rollout_strategy=Functionality.RECALL_FUNCTIONALITY)
     with self.assertRaises(NoAvailability):
         check_roll_out_recall(context=context)
Esempio n. 8
0
 def test_with_release_not_present(self):
     context = WhichContext()
     context.functionality = Functionality()
     with self.assertRaises(NoAvailability):
         assert_existence_of_release(context)
Esempio n. 9
0
 def test_roll_out_enable_globally_false(self):
     context = WhichContext()
     context.functionality = Functionality(
         rollout_strategy=Functionality.DEFINED_BY_RELEASES)
     availability = check_roll_out_enable_globally(context)
     self.assertIsNone(availability)
Esempio n. 10
0
 def test_roll_out_enable_globally_true(self):
     context = WhichContext()
     context.functionality = Functionality(
         rollout_strategy=Functionality.ENABLE_GLOBALLY)
     availability = check_roll_out_enable_globally(context)
     self.assertIsNotNone(availability)