def seeding(index: int, single: bool = False, save: bool = True) -> models.QuerySet: from apps.delivery_fee.serializers import DeliveryFeeBaseSr from .models import DeliveryFeeUnitPriceType if index == 0: raise Exception('Indext must be start with 1.') area = AreaUtils.seeding(1, True) def get_data(i: int) -> dict: data = { 'area': area.pk, 'start': i * 10, 'stop': i * 10 + 9, 'vnd_unit_price': int(200000 / i), 'type': DeliveryFeeUnitPriceType.MASS } if save is False: return data instance = DeliveryFeeBaseSr(data=data) instance.is_valid(raise_exception=True) instance = instance.save() return instance def get_list_data(index): return [get_data(i) for i in range(1, index + 1)] return get_data(index) if single is True else get_list_data(index)
def seeding(index: int, single: bool = False, save: bool = True) -> models.QuerySet: from .serializers import BagBaseSr if index == 0: raise Exception('Indext must be start with 1.') area = AreaUtils.seeding(1, True) staff = StaffUtils.seeding(1, True) def get_data(i: int) -> dict: data = { 'area': area.pk, 'staff': staff.pk, } if save is False: return data instance = BagBaseSr(data=data) instance.is_valid(raise_exception=True) instance = instance.save() return instance def get_list_data(index): return [get_data(i) for i in range(1, index + 1)] return get_data(index) if single is True else get_list_data(index)
def seeding(index: int, single: bool = False, save: bool = True) -> models.QuerySet: from apps.address.serializers import AddressBaseSr if index == 0: raise Exception('Indext must be start with 1.') customer = CustomerUtils.seeding(1, True) area = AreaUtils.seeding(1, True) def get_data(i: int) -> dict: data = { 'customer': customer.pk, 'area': area.pk, 'title': "title{}".format(i), 'phone': "phone{}".format(i), 'fullname': "fullname{}".format(i) } if save is False: return data instance = AddressBaseSr(data=data) instance.is_valid(raise_exception=True) instance = instance.save() return instance def get_list_data(index): return [get_data(i) for i in range(1, index + 1)] return get_data(index) if single is True else get_list_data(index)
def test_normal_case(self): area = AreaUtils.seeding(1, True) output = BagUtils.get_next_uid(area) eput = "{}{}1".format(area.uid, self.first_part) self.assertEqual(output, eput) Bag(area=area).save() output = BagUtils.get_next_uid(area) eput = "{}{}2".format(area.uid, self.first_part) self.assertEqual(output, eput) Bag(area=area).save() area = AreaUtils.seeding(2, True) output = BagUtils.get_next_uid(area) eput = "{}{}1".format(area.uid, self.first_part) self.assertEqual(output, eput)
def setUp(self): logging.disable(logging.CRITICAL) self.token = TestHelpers.test_setup() self.client = APIClient() self.client.credentials(HTTP_AUTHORIZATION='JWT ' + self.token) self.items = DeliveryFeeUtils.seeding(3) self.area = AreaUtils.seeding(1, True)
def setUp(self): self.area = AreaUtils.seeding(1, True) self.items = DeliveryFeeUtils.seeding(3)
def setUp(self): self.area = AreaUtils.seeding(1, True)