Example #1
0
    def test_all_features(self):
        """ Tests that the method returns a list of all feature names activated. """
        to_create = ['looktest1', 'looktest2', 'looktest3']
        for f in to_create:
            Feature(f).activate()

        all_features = Feature.all_features()
        self.assertEqual(len(all_features), len(to_create))
        for f in to_create:
            self.assertTrue(f in all_features)
Example #2
0
    def test_all_features(self):
        """ Tests that the method returns a list of all feature names activated. """
        to_create = ['looktest1', 'looktest2', 'looktest3']
        for f in to_create:
            Feature(f).activate()

        all_features = Feature.all_features()
        self.assertEqual(len(all_features), len(to_create))
        for f in to_create:
            self.assertTrue(f in all_features)
Example #3
0
    def test_all_features_with_data(self):
        """ Tests that the method returns the correct data with activated features. """
        feature1 = Feature('looktest1')
        feature1.set_percentage(5)

        feature2 = Feature('looktest2')
        feature2.activate()
        feature2.add_to_whitelist(3)

        feature3 = Feature('looktest3')
        feature3.activate()
        feature3.add_to_blacklist(4)
        feature3.add_to_blacklist(5)

        feature4 = Feature('looktest4')
        feature4.activate()
        feature4.add_to_whitelist(3)
        feature4.add_to_whitelist(5)
        feature4.add_to_blacklist(4)

        all_features = Feature.all_features(include_data=True)
        self.assertEqual(len(all_features), 4)

        for key in ['looktest1','looktest2','looktest3','looktest4']:
            self.assertTrue(key in all_features)
            if not key == 'looktest1':
                self.assertEqual(all_features[key]['percentage'], 100)

        self.assertEqual(all_features['looktest1']['percentage'], 5)
        self.assertFalse('whitelist' in all_features['looktest1'])
        self.assertFalse('blacklist' in all_features['looktest1'])

        self.assertTrue('whitelist' in all_features['looktest2'])
        self.assertEqual(all_features['looktest2']['whitelist'], [3])
        self.assertFalse('blacklist' in all_features['looktest2'])

        self.assertFalse('whitelist' in all_features['looktest3'])
        self.assertTrue('blacklist' in all_features['looktest3'])
        self.assertEqual(all_features['looktest3']['blacklist'], [4,5])

        self.assertTrue('whitelist' in all_features['looktest4'])
        self.assertEqual(all_features['looktest4']['whitelist'], [3, 5])
        self.assertTrue('blacklist' in all_features['looktest4'])
        self.assertEqual(all_features['looktest4']['blacklist'], [4])
Example #4
0
    def test_all_features_with_data(self):
        """ Tests that the method returns the correct data with activated features. """
        feature1 = Feature('looktest1')
        feature1.set_percentage(5)

        feature2 = Feature('looktest2')
        feature2.activate()
        feature2.add_to_whitelist(3)

        feature3 = Feature('looktest3')
        feature3.activate()
        feature3.add_to_blacklist(4)
        feature3.add_to_blacklist(5)

        feature4 = Feature('looktest4')
        feature4.activate()
        feature4.add_to_whitelist(3)
        feature4.add_to_whitelist(5)
        feature4.add_to_blacklist(4)

        all_features = Feature.all_features(include_data=True)
        self.assertEqual(len(all_features), 4)

        for key in ['looktest1', 'looktest2', 'looktest3', 'looktest4']:
            self.assertTrue(key in all_features)
            if not key == 'looktest1':
                self.assertEqual(all_features[key]['percentage'], 100)

        self.assertEqual(all_features['looktest1']['percentage'], 5)
        self.assertFalse('whitelist' in all_features['looktest1'])
        self.assertFalse('blacklist' in all_features['looktest1'])

        self.assertTrue('whitelist' in all_features['looktest2'])
        self.assertEqual(all_features['looktest2']['whitelist'], [3])
        self.assertFalse('blacklist' in all_features['looktest2'])

        self.assertFalse('whitelist' in all_features['looktest3'])
        self.assertTrue('blacklist' in all_features['looktest3'])
        self.assertEqual(all_features['looktest3']['blacklist'], [4, 5])

        self.assertTrue('whitelist' in all_features['looktest4'])
        self.assertEqual(all_features['looktest4']['whitelist'], [3, 5])
        self.assertTrue('blacklist' in all_features['looktest4'])
        self.assertEqual(all_features['looktest4']['blacklist'], [4])
Example #5
0
 def tearDown(self):
     for feature in Feature.all_features():
         Feature(feature).delete()
Example #6
0
 def tearDown(self):
     for feature in Feature.all_features():
         Feature(feature).delete()