def get_placebo_product(): """根据策略获取本次活动的体验金产品.""" product_ids = PlaceboProduct.get_ids_by_strategy( strategies.strategy_2016_spring.id_) if len(product_ids) != 1: raise RuntimeError('placebo products are dirty') product_id = first(product_ids) return PlaceboProduct.get(product_id)
def test_create_and_get(self): product = self._create_placebo_product() assert product.id_ > 0 assert PlaceboProduct.get(product.id_) == product assert product.min_amount == decimal.Decimal('100') assert product.max_amount == decimal.Decimal('200') assert PlaceboProduct.get_all_ids() == [product.id_] product2 = self._create_placebo_product() assert PlaceboProduct.get_all_ids() == [product2.id_, product.id_]
def test_get_nothing(self): assert PlaceboProduct.get(1) is None