def test_transport_register(self): bols = BolUtils.seeding(3) for bol in bols: bol.wooden_box = True bol.cny_wooden_box_fee = 2 bol.save() self.assertEqual(BolUtils.cal_wooden_box_fee(bol), 2)
def cal_wooden_box_fee(item: models.QuerySet) -> float: from apps.bol.utils import BolUtils # sum of bols's wooden box fee return sum([ BolUtils.cal_wooden_box_fee(bol) for bol in item.order_bols.all() ])