def test_sets_correct_is_enabled(self): name = self.txt() is_enabled = True meta = FeatureFlagStoreMeta(self.now, {}) item = FeatureFlagStoreItem(name, is_enabled, meta) serialized = item.serialize() deserialized = FeatureFlagStoreItem.deserialize(serialized) self.assertEqual(is_enabled, deserialized.is_enabled())
def test_returns_instance_of_class(self): name = self.txt() is_enabled = True meta = FeatureFlagStoreMeta(self.now, {}) item = FeatureFlagStoreItem(name, is_enabled, meta) serialized = item.serialize() deserialized = FeatureFlagStoreItem.deserialize(serialized) self.assertTrue(isinstance(deserialized, FeatureFlagStoreItem))
def test_sets_correct_value_in_redis_with_default(self): feature_name = self.txt() self.store.create(feature_name) key = "/".join([self.store.base_key, feature_name]) self.assertFalse( FeatureFlagStoreItem.deserialize(self.redis.get(key)).is_enabled())
def test_sets_correct_client_data(self): name = self.txt() is_enabled = True client_data = {"foo": "bar"} meta = FeatureFlagStoreMeta(self.now, client_data) item = FeatureFlagStoreItem(name, is_enabled, meta) serialized = item.serialize() deserialized = FeatureFlagStoreItem.deserialize(serialized) self.assertEqual(client_data, deserialized.to_dict()["meta"]["client_data"])
def test_sets_correct_value_in_s3_with_default(self): feature_name = self.txt() self.store.create(feature_name) serialized = self.client.get_object(Bucket=self.bucket_name, Key=feature_name)["Body"].read() self.assertFalse( FeatureFlagStoreItem.deserialize(serialized).is_enabled())