def orders_for_pagination(db): orders = Order.objects.bulk_create([ Order( token=str(uuid.uuid4()), total=TaxedMoney(net=Money(1, "USD"), gross=Money(1, "USD")), ), Order( token=str(uuid.uuid4()), total=TaxedMoney(net=Money(2, "USD"), gross=Money(2, "USD")), ), Order( token=str(uuid.uuid4()), total=TaxedMoney(net=Money(3, "USD"), gross=Money(3, "USD")), ), ]) return orders
def test_draft_orders_query_pagination_with_filter_search( draft_orders_filter, expected_total_count, orders_order, staff_api_client, permission_manage_orders, customer_user, draft_orders_for_pagination, ): Order.objects.bulk_create([ Order( user=customer_user, token=str(uuid.uuid4()), discount_name="test_discount1", user_email="*****@*****.**", translated_discount_name="translated_discount1_name", status=OrderStatus.DRAFT, ), Order( token=str(uuid.uuid4()), user_email="*****@*****.**", status=OrderStatus.DRAFT, ), Order( token=str(uuid.uuid4()), user_email="*****@*****.**", discount_name="test_discount2", translated_discount_name="translated_discount2_name", status=OrderStatus.DRAFT, ), ]) page_size = 2 variables = { "first": page_size, "after": None, "filter": draft_orders_filter } staff_api_client.user.user_permissions.add(permission_manage_orders) response = staff_api_client.post_graphql( QUERY_DRAFT_ORDERS_WITH_PAGINATION, variables) content = get_graphql_content(response) orders = content["data"]["draftOrders"]["edges"] total_count = content["data"]["draftOrders"]["totalCount"] assert expected_total_count == total_count for i in range(total_count if total_count < page_size else page_size): assert orders[i]["node"]["total"]["gross"]["amount"] == orders_order[i]
def test_webhooks(billing_address, customer_user, order: Order): mocked = DummyAdapter.send = MagicMock(wraps=DummyAdapter.send) to_hook = ( Order(billing_address=billing_address, user=customer_user, user_email=customer_user.email, total=Price(123, currency='USD')), User(email='*****@*****.**', password='******'), OrderNote(order=order, user=customer_user), ) for hook in to_hook: mocked.reset_mock() hook.save() embed = hook.webhook_embed(True).to_dict() DummyAdapter.send.assert_called_once_with(embed=embed)