def setUpTestData(cls): cls.client1 = ClientFactory() cls.billed_orders = OrderFactory.create_batch( 10, delivery_date=datetime.datetime.today(), client=cls.client1, status="D", ) cls.orders = OrderFactory.create_batch( 10, delivery_date=datetime.datetime.today(), client=ClientFactory(), status="O", )
def handle(self, *args, **options): orders = OrderFactory.create_batch(500, status='D') self.stdout.write( self.style.SUCCESS( 'Successfully created client {} orders'.format(orders) ) )
def setUp(self): self.today = datetime.datetime.today() self.billable_orders = OrderFactory.create_batch( 10, delivery_date=self.today, status="D", )
def test_physician_without_any_order(self): client = self.account.client category = CategoryFactory() OrderFactory(physician=AccountFactory(client=client), product=ProductFactory(category=category)) path = reverse('api:hospital:order:ordersummary_by_category', args=(client.id, category.id)) response = self.authorized_client.get(path) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data, [])
def setUp(self): super().setUp() self.account = AccountFactory( user=self.user, role=RoleFactory(priority=RolePriority.PHYSICIAN.value)) self.product = ProductFactory() preference = PreferenceFactory( client=self.account.client, questions=QuestionFactory.create_batch(3)) self.question_1, self.question_2, self.question_3 = preference.questions.all( ) OrderFactory.create_batch(2, physician=self.account, product=self.product, preference_questions=(self.question_1, self.question_2)) OrderFactory.create_batch(3, physician=self.account, product=self.product, preference_questions=(self.question_2, self.question_3)) self.path = reverse('api:hospital:order:order_preferences', args=(self.account.client.id, self.product.id))
def create_user_data(self, num_users: int, num_boards_per_user: int, num_addresses_per_user: int): for _ in range(num_users): user = UserFactory() for _ in range(num_boards_per_user): BoardFactory(owner=user) for _ in range(num_addresses_per_user - 2): AddressFactory(user=user) default_shipping_address = AddressFactory(is_shipping_default=True) default_billing_address = AddressFactory(is_billing_default=True) OrderFactory(user=user, shipping_address=default_shipping_address, billing_address=default_billing_address)
def handle(self, *args, **options): print("Generating {} number of order".format(options['total'])) items = OrderFactory.build_batch(int(options['total'])) counter = 10000 product_range = range(Product.objects.first().pk, Product.objects.last().pk + 1) customer_range = range(Product.objects.first().pk, Product.objects.last().pk + 1) def _presave_order(o): nonlocal counter o.order_no = counter o.customer_id = random.choice(customer_range) o.product_id = random.choice(product_range) counter += 1 return o Order.objects.bulk_create(_presave_order(p) for p in items)
def setUp(self): super().setUp() specialty = SpecialtyFactory() self.account = AccountFactory.create( role=RoleFactory(priority=RolePriority.PHYSICIAN.value), user=self.user, specialties=(specialty, )) self.account_foo = AccountFactory.create(user=self.account.user, specialties=(specialty, )) self.category_1 = CategoryFactory(specialty=specialty) self.category_2 = CategoryFactory(specialty=specialty) faker = Faker() self.category_1_orders = faker.random_int(min=1, max=20) self.category_2_orders = faker.random_int(min=1, max=20) self.other_orders = faker.random_int(min=1, max=20) self.total_num_orders = self.category_1_orders + self.category_2_orders + self.other_orders OrderFactory.create_batch( self.category_1_orders, physician=self.account, product=ProductFactory(category=self.category_1)) OrderFactory.create_batch( self.category_2_orders, physician=self.account, product=ProductFactory(category=self.category_2)) OrderFactory.create_batch( self.other_orders, physician=AccountFactory(client=self.account.client), product=ProductFactory(category=self.category_2)) OrderFactory.create_batch( 3, physician=self.account_foo, product=ProductFactory(category=self.category_1)) self.path = reverse('api:hospital:order:ordersummary', args=(self.account.client.id, ))
def setUp(self): super().setUp() specialty = SpecialtyFactory() self.account = AccountFactory.create( role=RoleFactory(priority=RolePriority.PHYSICIAN.value), user=self.user, specialties=(specialty, )) self.category_1 = CategoryFactory(specialty=specialty) self.category_2 = CategoryFactory(specialty=specialty) self.manufacturer_1 = ManufacturerFactory(image=ImageField( filename='Abbott.jpg')) self.manufacturer_2 = ManufacturerFactory(image=ImageField( filename='Simon.jpg')) self.product_1 = ProductFactory(category=self.category_1, manufacturer=self.manufacturer_1) self.product_2 = ProductFactory(category=self.category_2, manufacturer=self.manufacturer_2) self.product_3 = ProductFactory(category=self.category_1, manufacturer=self.manufacturer_2) faker = Faker() self.product_1_orders = faker.random_int(min=1, max=5) self.category_2_orders = faker.random_int(min=1, max=4) self.other_orders = faker.random_int(min=1, max=3) self.total_num_orders = self.product_1_orders + self.category_2_orders + self.other_orders OrderFactory.create_batch(self.product_1_orders, physician=self.account, product=self.product_1) OrderFactory.create_batch(self.category_2_orders, physician=self.account, product=self.product_2) OrderFactory.create_batch( self.other_orders, physician=AccountFactory(client=self.account.client), product=self.product_3) self.path = reverse('api:hospital:order:ordersummary_by_category', args=(self.account.client.id, self.category_1.id))
def test_order_to_string(self): order = OrderFactory(product=ProductFactory(name='Pacemaker'), procedure_datetime=datetime(2020, 1, 2, 3, 4, 5)) self.assertEqual(str(order), 'Pacemaker at 2020-01-02 03:04:05')
def handle(self, *args, **options): orders = OrderFactory.create_batch(500, status='D') self.stdout.write( self.style.SUCCESS( 'Successfully created client {} orders'.format(orders)))