def main(num_manufacturers, num_items_per_man, num_orders): mans = ManufacturerFactory.create_batch(num_manufacturers) print(f"Created {num_manufacturers} Manufacturers") items = list( chain.from_iterable([ ItemFactory.create_batch(num_items_per_man, manufacturer=man) for man in mans ])) print(f"Created {len(items)} Items") users = UserFactory.create_batch(50) for _ in range(0, num_orders): num_items = random.randint(5, 20) user = random.choice(users) OrderFactory.create(user=user, items=random.sample(items, num_items)) print(f"Created {num_orders} Orders")
def setUp(self): self.manufacturers = ManufacturerFactory.create_batch(size=5) self.cars = CarFactory.create_batch(size=5, make=self.manufacturers[0]) self.drivers = DriverFactory.create_batch(size=5, cars=[self.cars[0]])