def __init__( self, created_date: int, client_data: Optional[dict] = None, conditions: Optional[List[Condition]] = None, bucketer: Optional[AbstractBucketer] = None, ) -> None: self.created_date = created_date self.client_data = client_data or {} self.conditions = conditions or [] self.bucketer = bucketer or NoOpBucketer()
def _has_bucketer(self) -> bool: return self._meta.bucketer.get_type() != NoOpBucketer.get_type()
def test_is_correct_value(self): bucketer = NoOpBucketer() self.assertEqual("NoOpBucketer", bucketer.get_type())
def test_sets_correct_data(self): data = {"type": NoOpBucketer.get_type()} bucketer = NoOpBucketer.from_dict(data) self.assertEqual(data, bucketer.to_dict())
def test_returns_correct_data(self): bucketer = NoOpBucketer() expected = {"type": NoOpBucketer.get_type()} self.assertEqual(expected, bucketer.to_dict())
def test_always_returns_true_with_checks(self): bucketer = NoOpBucketer() self.assertTrue(bucketer.check(foo=1))
def test_creates_noop_bucketer(self): bucketer = BucketerFactory.create({"type": NoOpBucketer.get_type()}) self.assertIsInstance(bucketer, NoOpBucketer)