Exemplo n.º 1
0
 def test_Default_DisabledByDefault(self):
     f = FeatureFlag(value=BoolFlag.DEFAULT,
                     behaviorOfDefault=BoolFlag.DISABLED)
     self.assertEqual(False, bool(f))
     self.assertEqual(BoolFlag.DISABLED, f.calculated())
     self.assertTrue(f == BoolFlag.DISABLED)  # overloaded operator ==
     self.assertEqual(f.enumClassType, BoolFlag)
Exemplo n.º 2
0
 def test_Enabled_EnabledByDefault(self):
     f = FeatureFlag(value=BoolFlag.ENABLED,
                     behaviorOfDefault=BoolFlag.ENABLED)
     self.assertEqual(True, bool(f))
     self.assertEqual(BoolFlag.ENABLED, f.calculated())
     self.assertTrue(f == BoolFlag.ENABLED)  # overloaded operator ==
     self.assertEqual(f.enumClassType, BoolFlag)
Exemplo n.º 3
0
    def test_CustomEnum_equalsOp(self):
        always = FeatureFlag(value=CustomEnum.ALWAYS,
                             behaviorOfDefault=CustomEnum.NEVER)

        alsoAlways = FeatureFlag(value=CustomEnum.ALWAYS,
                                 behaviorOfDefault=CustomEnum.NEVER)
        whenRequired = FeatureFlag(value=CustomEnum.WHEN_REQUIRED,
                                   behaviorOfDefault=CustomEnum.NEVER)
        defaultAlways = FeatureFlag(value=CustomEnum.DEFAULT,
                                    behaviorOfDefault=CustomEnum.ALWAYS)
        defaultNever = FeatureFlag(value=CustomEnum.DEFAULT,
                                   behaviorOfDefault=CustomEnum.NEVER)

        self.assertFalse(always.isDefault())
        self.assertTrue(defaultAlways.isDefault())

        # overloaded operator == accepts enum or featureFlag
        self.assertTrue(always == CustomEnum.ALWAYS)
        self.assertTrue(always == alsoAlways)
        self.assertTrue(whenRequired == CustomEnum.WHEN_REQUIRED)
        self.assertTrue(whenRequired != alsoAlways)
        self.assertTrue(defaultAlways == CustomEnum.ALWAYS)
        self.assertTrue(defaultAlways == always)
        self.assertTrue(defaultNever == CustomEnum.NEVER)
Exemplo n.º 4
0
 def test_CustomEnum_boolRaises(self):
     f = FeatureFlag(value=CustomEnum.ALWAYS,
                     behaviorOfDefault=CustomEnum.NEVER)
     with self.assertRaises(NotImplementedError):
         bool(f)
Exemplo n.º 5
0
 def test_DefaultBehaviorOfDefault_Raises(self):
     with self.assertRaises(AssertionError):
         FeatureFlag(value=BoolFlag.DEFAULT,
                     behaviorOfDefault=BoolFlag.DEFAULT)