• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_graphql_content函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.api.utils.get_graphql_content函数的典型用法代码示例。如果您正苦于以下问题:Python get_graphql_content函数的具体用法?Python get_graphql_content怎么用?Python get_graphql_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_graphql_content函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_menu_query

def test_menu_query(user_api_client, menu):
    query = """
    query menu($id: ID, $menu_name: String){
        menu(id: $id, name: $menu_name) {
            name
        }
    }
    """

    # test query by name
    variables = {"menu_name": menu.name}
    response = user_api_client.post_graphql(query, variables)
    content = get_graphql_content(response)
    assert content["data"]["menu"]["name"] == menu.name

    # test query by id
    menu_id = graphene.Node.to_global_id("Menu", menu.id)
    variables = {"id": menu_id}
    response = user_api_client.post_graphql(query, variables)
    content = get_graphql_content(response)
    assert content["data"]["menu"]["name"] == menu.name

    # test query by invalid name returns null
    variables = {"menu_name": "not-a-menu"}
    response = user_api_client.post_graphql(query, variables)
    content = get_graphql_content(response)
    assert not content["data"]["menu"]
开发者ID:mirumee,项目名称:saleor,代码行数:27,代码来源:test_menu.py


示例2: test_digital_content_create_mutation_default_settings

def test_digital_content_create_mutation_default_settings(
        monkeypatch, staff_api_client, variant, permission_manage_products):
    query = """
    mutation digitalCreate($variant: ID!, 
        $input: DigitalContentUploadInput!) {
        digitalContentCreate(variantId: $variant, input: $input) {
            variant {
                id
            }
        }
    }
    """

    image_file, image_name = create_image()

    variables = {
        'variant': graphene.Node.to_global_id('ProductVariant', variant.id),
        'input': {
            'useDefaultSettings': True,
            'contentFile': image_name
        }
    }

    body = get_multipart_request_body(query, variables, image_file, image_name)
    response = staff_api_client.post_multipart(
        body, permissions=[permission_manage_products])
    get_graphql_content(response)
    variant.refresh_from_db()
    assert variant.digital_content.content_file
    assert variant.digital_content.use_default_settings
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:30,代码来源:test_digital_content.py


示例3: test_digital_content_delete_mutation

def test_digital_content_delete_mutation(
        monkeypatch, staff_api_client, variant, digital_content,
        permission_manage_products):
    query = """
    mutation digitalDelete($variant: ID!){
        digitalContentDelete(variantId:$variant){
            variant{
              id
            }
        }
    }
    """

    variant.digital_content = digital_content
    variant.digital_content.save()

    assert hasattr(variant, 'digital_content')
    variables = {
        'variant': graphene.Node.to_global_id('ProductVariant', variant.id)
    }

    response = staff_api_client.post_graphql(
        query, variables, permissions=[permission_manage_products])
    get_graphql_content(response)
    variant = ProductVariant.objects.get(id=variant.id)
    assert not hasattr(variant, 'digital_content')
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:26,代码来源:test_digital_content.py


示例4: test_digital_content_url_create

def test_digital_content_url_create(
        monkeypatch, staff_api_client, variant, permission_manage_products,
        digital_content):
    query = """
    mutation digitalContentUrlCreate($input: DigitalContentUrlCreateInput!) {
        digitalContentUrlCreate(input: $input) {
            digitalContentUrl {
                id
                url
            }
            errors {
                field
                message
            }
        }
    }
    """

    variables = {
        'input': {
            'content': graphene.Node.to_global_id(
                'DigitalContent', digital_content.id),
        }
    }

    assert digital_content.urls.count() == 0
    response = staff_api_client.post_graphql(
        query, variables, permissions=[permission_manage_products])
    get_graphql_content(response)

    digital_content.refresh_from_db()
    assert digital_content.urls.count() == 1
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:32,代码来源:test_digital_content.py


示例5: test_use_checkout_billing_address_as_payment_billing

def test_use_checkout_billing_address_as_payment_billing(
        user_api_client, cart_with_item, address):
    cart = cart_with_item
    checkout_id = graphene.Node.to_global_id('Checkout', cart.pk)
    variables = {
        'checkoutId': checkout_id,
        'input': {
            'gateway': 'DUMMY',
            'token': 'sample-token',
            'amount': str(cart.get_total().gross.amount)}}
    response = user_api_client.post_graphql(CREATE_QUERY, variables)
    content = get_graphql_content(response)
    data = content['data']['checkoutPaymentCreate']

    # check if proper error is returned if address is missing
    assert data['errors'][0]['field'] == 'billingAddress'

    # assign the address and try again
    address.street_address_1 = 'spanish-inqusition'
    address.save()
    cart.billing_address = address
    cart.save()
    response = user_api_client.post_graphql(CREATE_QUERY, variables)
    content = get_graphql_content(response)
    data = content['data']['checkoutPaymentCreate']

    cart.refresh_from_db()
    assert cart.payments.count() == 1
    payment = cart.payments.first()
    assert payment.billing_address_1 == address.street_address_1
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:30,代码来源:test_payment.py


示例6: test_use_checkout_billing_address_as_payment_billing

def test_use_checkout_billing_address_as_payment_billing(
    user_api_client, checkout_with_item, address
):
    checkout = checkout_with_item
    checkout_id = graphene.Node.to_global_id("Checkout", checkout.pk)
    variables = {
        "checkoutId": checkout_id,
        "input": {
            "gateway": "DUMMY",
            "token": "sample-token",
            "amount": str(checkout.get_total().gross.amount),
        },
    }
    response = user_api_client.post_graphql(CREATE_QUERY, variables)
    content = get_graphql_content(response)
    data = content["data"]["checkoutPaymentCreate"]

    # check if proper error is returned if address is missing
    assert data["errors"][0]["field"] == "billingAddress"

    # assign the address and try again
    address.street_address_1 = "spanish-inqusition"
    address.save()
    checkout.billing_address = address
    checkout.save()
    response = user_api_client.post_graphql(CREATE_QUERY, variables)
    content = get_graphql_content(response)
    data = content["data"]["checkoutPaymentCreate"]

    checkout.refresh_from_db()
    assert checkout.payments.count() == 1
    payment = checkout.payments.first()
    assert payment.billing_address_1 == address.street_address_1
开发者ID:mirumee,项目名称:saleor,代码行数:33,代码来源:test_payment.py


示例7: test_staff_query_unpublished_page

def test_staff_query_unpublished_page(staff_api_client, page, permission_manage_pages):
    page.is_published = False
    page.save()

    # query by ID
    variables = {"id": graphene.Node.to_global_id("Page", page.id)}
    response = staff_api_client.post_graphql(PAGE_QUERY, variables)
    content = get_graphql_content(response)
    assert content["data"]["page"] is None
    # query by slug
    variables = {"slug": page.slug}
    response = staff_api_client.post_graphql(PAGE_QUERY, variables)
    content = get_graphql_content(response)
    assert content["data"]["page"] is None

    # query by ID with page permissions
    variables = {"id": graphene.Node.to_global_id("Page", page.id)}
    response = staff_api_client.post_graphql(
        PAGE_QUERY,
        variables,
        permissions=[permission_manage_pages],
        check_no_permissions=False,
    )
    content = get_graphql_content(response)
    assert content["data"]["page"] is not None
    # query by slug with page permissions
    variables = {"slug": page.slug}
    response = staff_api_client.post_graphql(
        PAGE_QUERY,
        variables,
        permissions=[permission_manage_pages],
        check_no_permissions=False,
    )
    content = get_graphql_content(response)
    assert content["data"]["page"] is not None
开发者ID:mirumee,项目名称:saleor,代码行数:35,代码来源:test_page.py


示例8: test_shop_fetch_tax_rates

def test_shop_fetch_tax_rates(
        mock_call_command, staff_api_client, permission_manage_settings,
        settings):
    settings.VATLAYER_ACCESS_KEY = 'KEY'
    staff_api_client.user.user_permissions.add(permission_manage_settings)
    response = staff_api_client.post_graphql(
        MUTATION_SHOP_FETCH_TAX_RATES)
    get_graphql_content(response)
    mock_call_command.assert_called_once_with('get_vat_rates')
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:9,代码来源:test_shop.py


示例9: test_assign_menu

def test_assign_menu(
    staff_api_client,
    menu,
    permission_manage_menus,
    permission_manage_settings,
    site_settings,
):
    query = """
    mutation AssignMenu($menu: ID, $navigationType: NavigationType!) {
        assignNavigation(menu: $menu, navigationType: $navigationType) {
            errors {
                field
                message
            }
            menu {
                name
            }
        }
    }
    """

    # test mutations fails without proper permissions
    menu_id = graphene.Node.to_global_id("Menu", menu.pk)
    variables = {"menu": menu_id, "navigationType": NavigationType.MAIN.name}
    response = staff_api_client.post_graphql(query, variables)
    assert_no_permission(response)

    staff_api_client.user.user_permissions.add(permission_manage_menus)
    staff_api_client.user.user_permissions.add(permission_manage_settings)

    # test assigning main menu
    response = staff_api_client.post_graphql(query, variables)
    content = get_graphql_content(response)
    assert content["data"]["assignNavigation"]["menu"]["name"] == menu.name
    site_settings.refresh_from_db()
    assert site_settings.top_menu.name == menu.name

    # test assigning secondary menu
    variables = {"menu": menu_id, "navigationType": NavigationType.SECONDARY.name}
    response = staff_api_client.post_graphql(query, variables)
    content = get_graphql_content(response)
    assert content["data"]["assignNavigation"]["menu"]["name"] == menu.name
    site_settings.refresh_from_db()
    assert site_settings.bottom_menu.name == menu.name

    # test unasigning menu
    variables = {"id": None, "navigationType": NavigationType.MAIN.name}
    response = staff_api_client.post_graphql(query, variables)
    content = get_graphql_content(response)
    assert not content["data"]["assignNavigation"]["menu"]
    site_settings.refresh_from_db()
    assert site_settings.top_menu is None
开发者ID:mirumee,项目名称:saleor,代码行数:52,代码来源:test_menu.py


示例10: test_customer_query_unpublished_page

def test_customer_query_unpublished_page(user_api_client, page):
    page.is_published = False
    page.save()

    # query by ID
    variables = {'id': graphene.Node.to_global_id('Page', page.id)}
    response = user_api_client.post_graphql(PAGE_QUERY, variables)
    content = get_graphql_content(response)
    assert content['data']['page'] is None

    # query by slug
    variables = {'slug': page.slug}
    response = user_api_client.post_graphql(PAGE_QUERY, variables)
    content = get_graphql_content(response)
    assert content['data']['page'] is None
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:15,代码来源:test_page.py


示例11: test_attribute_translation

def test_attribute_translation(user_api_client, color_attribute):
    color_attribute.translations.create(language_code='pl', name='Kolor')

    query = """
    query {
        attributes(first: 1) {
            edges {
                node {
                    translation(languageCode: PL) {
                        name
                        language {
                            code
                        }
                    }
                }
            }
        }
    }
    """

    response = user_api_client.post_graphql(query)
    data = get_graphql_content(response)['data']

    attribute = data['attributes']['edges'][0]['node']
    assert attribute['translation']['name'] == 'Kolor'
    assert attribute['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:26,代码来源:test_translations.py


示例12: test_translations_query_inline_fragment

def test_translations_query_inline_fragment(user_api_client, product):
    product.translations.create(language_code='pl', name='Produkt testowy')

    query = """
    {
        translations(kind: PRODUCT, first: 1) {
            edges {
                node {
                    ... on Product {
                        name
                        translation(languageCode: PL) {
                            name
                        }
                    }
                }
            }
        }
    }
    """

    response = user_api_client.post_graphql(query)
    data = get_graphql_content(response)['data']['translations']['edges'][0]

    assert data['node']['name'] == 'Test product'
    assert data['node']['translation']['name'] == 'Produkt testowy'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:25,代码来源:test_translations.py


示例13: test_shop_update_translation

def test_shop_update_translation(
        staff_api_client, site_settings, permission_manage_translations):
    site_settings.translations.create(
        language_code='pl', header_text='Nagłówek')

    query = """
    mutation shopSettingsTranslate {
        shopSettingsTranslate(
                languageCode: PL, input: {headerText: "Nagłówek PL"}) {
            shop {
                translation(languageCode: PL) {
                    headerText
                    language {
                        code
                    }
                }
            }
        }
    }
    """

    response = staff_api_client.post_graphql(
        query, permissions=[permission_manage_translations])
    data = get_graphql_content(response)['data']['shopSettingsTranslate']

    assert data['shop']['translation']['headerText'] == 'Nagłówek PL'
    assert data['shop']['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:27,代码来源:test_translations.py


示例14: test_menu_item_update_translation

def test_menu_item_update_translation(
        staff_api_client, menu_item, permission_manage_translations):
    menu_item.translations.create(language_code='pl', name='Odnośnik')

    query = """
    mutation menuItemTranslate($menuItemId: ID!) {
        menuItemTranslate(
                id: $menuItemId, languageCode: PL,
                input: {name: "Odnośnik PL"}) {
            menuItem {
                translation(languageCode: PL) {
                    name
                    language {
                        code
                    }
                }
            }
        }
    }
    """

    menu_item_id = graphene.Node.to_global_id('MenuItem', menu_item.id)
    response = staff_api_client.post_graphql(
        query, {'menuItemId': menu_item_id},
        permissions=[permission_manage_translations])
    data = get_graphql_content(response)['data']['menuItemTranslate']

    assert data['menuItem']['translation']['name'] == 'Odnośnik PL'
    assert data['menuItem']['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:29,代码来源:test_translations.py


示例15: test_shipping_method_update_translation

def test_shipping_method_update_translation(
        staff_api_client, shipping_method, permission_manage_translations):
    shipping_method.translations.create(language_code='pl', name='DHL')

    query = """
    mutation shippingPriceTranslate($shippingMethodId: ID!) {
        shippingPriceTranslate(
                id: $shippingMethodId, languageCode: PL,
                input: {name: "DHL PL"}) {
            shippingMethod {
                translation(languageCode: PL) {
                    name
                    language {
                        code
                    }
                }
            }
        }
    }
    """

    shipping_method_id = graphene.Node.to_global_id(
        'ShippingMethod', shipping_method.id)
    response = staff_api_client.post_graphql(
        query, {'shippingMethodId': shipping_method_id},
        permissions=[permission_manage_translations])
    data = get_graphql_content(response)['data']['shippingPriceTranslate']

    assert data['shippingMethod']['translation']['name'] == 'DHL PL'
    assert data['shippingMethod']['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:30,代码来源:test_translations.py


示例16: test_voucher_translation

def test_voucher_translation(
        staff_api_client, voucher, permission_manage_discounts):
    voucher.translations.create(language_code='pl', name='Bon')

    query = """
    query voucherById($voucherId: ID!) {
        voucher(id: $voucherId) {
            translation(languageCode: PL) {
                name
                language {
                    code
                }
            }
        }
    }
    """

    voucher_id = graphene.Node.to_global_id('Voucher', voucher.id)
    response = staff_api_client.post_graphql(
        query, {'voucherId': voucher_id},
        permissions=[permission_manage_discounts])
    data = get_graphql_content(response)['data']

    assert data['voucher']['translation']['name'] == 'Bon'
    assert data['voucher']['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:25,代码来源:test_translations.py


示例17: test_page_update_translation

def test_page_update_translation(
        staff_api_client, page, permission_manage_translations):
    page.translations.create(language_code='pl', title='Strona')

    query = """
    mutation pageTranslate($pageId: ID!) {
        pageTranslate(
                id: $pageId, languageCode: PL,
                input: {title: "Strona PL"}) {
            page {
                translation(languageCode: PL) {
                    title
                    language {
                        code
                    }
                }
            }
        }
    }
    """

    page_id = graphene.Node.to_global_id('Page', page.id)
    response = staff_api_client.post_graphql(
        query, {'pageId': page_id},
        permissions=[permission_manage_translations])
    data = get_graphql_content(response)['data']['pageTranslate']

    assert data['page']['translation']['title'] == 'Strona PL'
    assert data['page']['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:29,代码来源:test_translations.py


示例18: test_category_update_translation

def test_category_update_translation(
        staff_api_client, category, permission_manage_translations):
    category.translations.create(language_code='pl', name='Kategoria')

    query = """
    mutation categoryTranslate($categoryId: ID!) {
        categoryTranslate(
                id: $categoryId, languageCode: PL,
                input: {name: "Kategoria PL"}) {
            category {
                translation(languageCode: PL) {
                    name
                    language {
                        code
                    }
                }
            }
        }
    }
    """

    category_id = graphene.Node.to_global_id('Category', category.id)
    response = staff_api_client.post_graphql(
        query, {'categoryId': category_id},
        permissions=[permission_manage_translations])
    data = get_graphql_content(response)['data']['categoryTranslate']

    assert data['category']['translation']['name'] == 'Kategoria PL'
    assert data['category']['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:29,代码来源:test_translations.py


示例19: test_product_variant_update_translation

def test_product_variant_update_translation(
        staff_api_client, variant, permission_manage_translations):
    variant.translations.create(language_code='pl', name='Wariant')

    query = """
    mutation productVariantTranslate($productVariantId: ID!) {
        productVariantTranslate(
                id: $productVariantId, languageCode: PL,
                input: {name: "Wariant PL"}) {
            productVariant {
                translation(languageCode: PL) {
                    name
                    language {
                        code
                    }
                }
            }
        }
    }
    """

    product_variant_id = graphene.Node.to_global_id(
        'ProductVariant', variant.id)
    response = staff_api_client.post_graphql(
        query, {'productVariantId': product_variant_id},
        permissions=[permission_manage_translations])
    data = get_graphql_content(response)['data']['productVariantTranslate']

    assert data['productVariant']['translation']['name'] == 'Wariant PL'
    assert data['productVariant']['translation']['language']['code'] == 'pl'
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:30,代码来源:test_translations.py


示例20: test_attribute_value_no_translation

def test_attribute_value_no_translation(user_api_client, pink_attribute_value):
    query = """
    query {
        attributes(first: 1) {
            edges {
                node {
                    values {
                        translation(languageCode: PL) {
                            name
                            language {
                                code
                            }
                        }
                    }
                }
            }
        }
    }
    """

    attribute_value_id = graphene.Node.to_global_id(
        'AttributeValue', pink_attribute_value.id)
    response = user_api_client.post_graphql(
        query, {'attributeValueId': attribute_value_id})
    data = get_graphql_content(response)['data']

    attribute_value = data['attributes']['edges'][0]['node']['values'][-1]
    assert attribute_value['translation'] is None
开发者ID:krzysztofwolski,项目名称:saleor,代码行数:28,代码来源:test_translations.py



注:本文中的tests.api.utils.get_graphql_content函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_path函数代码示例发布时间:2022-05-27
下一篇:
Python test_api.make_runtime_storage函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap