当前位置: 首页>>代码示例>>Python>>正文


Python Schema.execute方法代码示例

本文整理汇总了Python中assembl.graphql.schema.Schema.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Schema.execute方法的具体用法?Python Schema.execute怎么用?Python Schema.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在assembl.graphql.schema.Schema的用法示例。


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

示例1: test_mutation_add_extracts

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_mutation_add_extracts(graphql_request, top_post_in_thread_phase):
  post_db_id = int(from_global_id(top_post_in_thread_phase)[1])
  
  extract_body = u"manger des choux à la crème"
  xpathStart = u"//div[@id='message-body-local:Content/%s']/" % post_db_id
  xpathEnd = xpathStart
  offsetStart = 17
  offsetEnd = 44

  variable_values = {
    "extracts": [
      {
        "postId": top_post_in_thread_phase,
        "body": extract_body,
        "xpathStart": xpathStart,  
        "xpathEnd": xpathEnd,
        "offsetStart": offsetStart,
        "offsetEnd": offsetEnd,
        "lang": "fr"
      }
    ],
    "extractState": "SUBMITTED",
    "extractNature": "actionable_solution" 
  }

  post = models.AssemblPost.get(post_db_id)
  db = post.db
  def get_extracts():
      return db.query(
        models.Extract
        ).join(
        models.Content, models.Extract.content == post
        ).options(joinedload(models.Extract.text_fragment_identifiers)).all()

  assert len(get_extracts()) == 0
  res = schema.execute(u"""
mutation AddPostsExtract($extracts: [PostExtractEntryInput]!, $extractState: ExtractStates, $extractNature: ExtractNatures) {
  addPostsExtract(extracts: $extracts, extractState: $extractState, extractNature: $extractNature) {
    status
  }
}
""", context_value=graphql_request, variable_values=variable_values)

  assert json.loads(json.dumps(res.data)) == {
    u'addPostsExtract': {
      u'status': True
    }
  }
  assert len(get_extracts()) == 1

  # add the same extract
  res = schema.execute(u"""
mutation AddPostsExtract($extracts: [PostExtractEntryInput]!, $extractState: ExtractStates, $extractNature: ExtractNatures) {
  addPostsExtract(extracts: $extracts, extractState: $extractState, extractNature: $extractNature) {
    status
  }
}
""", context_value=graphql_request, variable_values=variable_values)
  # The extract must be ignored
  assert len(get_extracts()) == 1
开发者ID:assembl,项目名称:assembl,代码行数:62,代码来源:test_graphql_extracts.py

示例2: test_delete_resource

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_delete_resource(graphql_registry, graphql_request, resource):
    resource_id = to_global_id('Resource', resource.id)
    res = schema.execute(
        graphql_registry['deleteResource'],
        variable_values={
            "resourceId": resource_id
        },
        context_value=graphql_request)
    assert res.data['deleteResource']['success'] is True
    res = schema.execute(
        u'query { resources { id } }', context_value=graphql_request)
    assert json.loads(json.dumps(res.data)) == {u'resources': []}
开发者ID:assembl,项目名称:assembl,代码行数:14,代码来源:test_graphql_resources_center.py

示例3: test_mutation_delete_template_also_deletes_associated_vote_specifications

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_mutation_delete_template_also_deletes_associated_vote_specifications(graphql_request, vote_session, vote_proposal, graphql_registry, test_session):
    mutation = graphql_registry['createTokenVoteSpecification']
    vote_session_id = to_global_id("VoteSession", vote_session.id)
    from assembl.graphql.schema import Schema as schema
    res = schema.execute(mutation, context_value=graphql_request, variable_values={
        "voteSessionId": vote_session_id,
        "titleEntries": [],
        "instructionsEntries":
        [
            {"value": u"Try to copy the TCP feed, maybe it will navigate the mobile system!", "localeCode": "en"}
        ],
        "isCustom": False,
        "exclusiveCategories": False,
        "tokenCategories": [
            {
                "titleEntries": [{"value": u"In favor", "localeCode": "en"}],
                "typename": "positive",
                "totalNumber": 9,
                "color": 'green'
            }
        ]
    })
    assert res.errors is None
    template_id = res.data['createTokenVoteSpecification']['voteSpecification']['id']
    proposal_id = to_global_id("Idea", vote_proposal.id)

    res = schema.execute(mutation, context_value=graphql_request, variable_values={
        "voteSessionId": vote_session_id,
        "proposalId": proposal_id,
        "voteSpecTemplateId": template_id,
        "titleEntries": [],
        "instructionsEntries":
        [
            {"value": u"I'll compress the multi-byte THX protocol, that should panel the SDD monitor!", "localeCode": "en"}
        ],
        "isCustom": True,
        "exclusiveCategories": False,
        "tokenCategories": []
    })
    assert res.errors is None

    # delete the template
    mutation = graphql_registry['deleteVoteSpecification']
    vote_spec_id = res.data['createTokenVoteSpecification']['voteSpecification']['id']
    res = schema.execute(mutation, context_value=graphql_request, variable_values={
        "id": template_id
    })
    assert res.errors is None
    assert res.data['deleteVoteSpecification']['success'] is True
    # the template and the vote spec have been deleted
    assert test_session.query(models.TokenVoteSpecification).count() == 0
开发者ID:assembl,项目名称:assembl,代码行数:53,代码来源:test_graphql_vote_session.py

示例4: test_query_associate_vote_spec_to_proposal

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_query_associate_vote_spec_to_proposal(graphql_request, timeline_vote_session, vote_session, vote_proposal, token_vote_specification, graphql_registry):
    mutation = graphql_registry['createTokenVoteSpecification']
    vote_session_id = to_global_id("VoteSession", vote_session.id)
    proposal_id = to_global_id("Idea", vote_proposal.id)
    # token vote spec similar to token_vote_specification fixture, but with exclusiveCategories set to False
    template_token_vote_spec_id = to_global_id("TokenVoteSpecification", token_vote_specification.id)
    res = schema.execute(mutation, context_value=graphql_request, variable_values={
        "voteSessionId": vote_session_id,
        "proposalId": proposal_id,
        "voteSpecTemplateId": template_token_vote_spec_id,
        "titleEntries": [
            {"value": u"Comprendre les dynamiques et les enjeux", "localeCode": "fr"},
            {"value": u"Understanding the dynamics and issues", "localeCode": "en"}
        ],
        "instructionsEntries":
        [
            {"value": u"Comprendre les dynamiques et les enjeux", "localeCode": "fr"},
            {"value": u"Understanding the dynamics and issues", "localeCode": "en"}
        ],
        "isCustom": True,
        "exclusiveCategories": False,
        "tokenCategories": [
            {"titleEntries": [
                {"value": u"Comprendre les dynamiques et les enjeux", "localeCode": "fr"},
                {"value": u"Understanding the dynamics and issues", "localeCode": "en"}
             ],
             "typename": "positive",
             "totalNumber": 10,
             "color": 'red'
            }
        ]
    })
    query = graphql_registry['VoteSession']
    res = schema.execute(query, context_value=graphql_request, variable_values={
        "ideaId": to_global_id('Idea',vote_session.idea_id),
        "lang": "en"
    })
    assert res.errors is None
    proposal_id = to_global_id("Idea", vote_proposal.id)
    assert len(res.data['voteSession']['modules']) == 1  # only vote spec not associated to a proposal
    assert res.data['voteSession']['modules'][0]['exclusiveCategories'] == True
    assert len(res.data['voteSession']['proposals'][0]['modules']) == 1
    assert res.data['voteSession']['proposals'][0]['modules'][0]['exclusiveCategories'] == False
    assert res.data['voteSession']['proposals'][0]['modules'][0]['voteSpecTemplateId'] == template_token_vote_spec_id
    assert res.data['voteSession']['proposals'][0]['modules'][0]['isCustom'] is True

    # clean up
    vote_session.vote_specifications[-1].delete()
    vote_session.db.flush()
开发者ID:assembl,项目名称:assembl,代码行数:51,代码来源:test_graphql_vote_session.py

示例5: test_query_tags

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_query_tags(graphql_request, extract_post_1_to_subidea_1_1):
  variable_values = {
    "filter": ''
  }

  res = schema.execute(u"""
query tags($filter: String) {
  tags(filter: $filter) {
    value
  }
}
""", context_value=graphql_request, variable_values=variable_values)

  assert json.loads(json.dumps(res.data)) == {
    u'tags': [{u'value': u'foo'}, {u'value': u'bar'}]
  }

  variable_values = {
    "filter": 'f'
  }

  res = schema.execute(u"""
query tags($filter: String) {
  tags(filter: $filter) {
    value
  }
}
""", context_value=graphql_request, variable_values=variable_values)

  assert json.loads(json.dumps(res.data)) == {
    u'tags': [{u'value': u'foo'}]
  }

  variable_values = {
    "filter": 'test'
  }

  res = schema.execute(u"""
query tags($filter: String) {
  tags(filter: $filter) {
    value
  }
}
""", context_value=graphql_request, variable_values=variable_values)

  assert json.loads(json.dumps(res.data)) == {
    u'tags': []
  }
开发者ID:assembl,项目名称:assembl,代码行数:50,代码来源:test_graphql_tags.py

示例6: test_mutation_update_text_field

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_mutation_update_text_field(graphql_request, graphql_registry, text_field):
    text_field_id = to_global_id('TextField', text_field.id)
    res = schema.execute(
        graphql_registry['updateTextField'],
        context_value=graphql_request,
        variable_values={
            "id": text_field_id,
            "lang": u"en",
            "titleEntries": [
                { "localeCode": "en", "value": u"My new title" },
                { "localeCode": "be", "value": u"Mon nouveau titre" },
            ],
            "order": 8.0,
            "required": False,
            "hidden": False
        })
    assert res.errors is None
    assert 'updateTextField' in res.data
    field = res.data['updateTextField']['field']
    assert field[u'required'] is False
    assert field[u'hidden'] is False
    assert field[u'order'] == 8.0
    title_entries = field['titleEntries']
    assert title_entries[0]['localeCode'] == u'be'
    assert title_entries[0]['value'] == u'Mon nouveau titre'
    assert title_entries[1]['localeCode'] == u'en'
    assert title_entries[1]['value'] == u'My new title'
开发者ID:assembl,项目名称:assembl,代码行数:29,代码来源:test_graphql_configurable_fields.py

示例7: test_mutation_create_text_field

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_mutation_create_text_field(graphql_request, graphql_registry, test_session):
    from assembl.models.configurable_fields import TextField
    res = schema.execute(
        graphql_registry['createTextField'],
        context_value=graphql_request,
        variable_values={
            "lang": u"en",
            "titleEntries": [
                { "localeCode": "en", "value": u"My new field" }
            ],
            "order": 4.0,
            "required": False,
            "hidden": False
        })
    assert res.errors is None
    assert 'createTextField' in res.data
    new_field = res.data['createTextField']['field']
    assert new_field[u'required'] is False
    assert new_field[u'hidden'] is False
    assert new_field[u'order'] == 4.0
    title_entries = new_field['titleEntries']
    assert title_entries[0]['localeCode'] == u'en'
    assert title_entries[0]['value'] == u'My new field'
    saobj = TextField.get(from_global_id(new_field[u'id'])[1])
    test_session.delete(saobj)
开发者ID:assembl,项目名称:assembl,代码行数:27,代码来源:test_graphql_configurable_fields.py

示例8: thematic_with_image

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def thematic_with_image(phases, graphql_request):
    from assembl.graphql.schema import Schema as schema
    import os
    from io import BytesIO

    class FieldStorage(object):
        file = BytesIO(os.urandom(16))
        filename = u'path/to/image.png'
        type = 'image/png'

    graphql_request.POST['variables.file'] = FieldStorage()
    res = schema.execute(u"""
mutation createThematicWithImage($file: String!) {
    createThematic(
        messageViewOverride: "survey",
        titleEntries:[
            {value:"You can't program the card without transmitting the wireless AGP card!", localeCode:"en"}
        ],
        discussionPhaseId: """+unicode(phases['survey'].id)+u""",
        image: $file
    ) {
        thematic {
            ... on Idea {
                id,
                img { externalUrl }
            }
        }
    }
}
""", context_value=graphql_request, variable_values={ "file": "variables.file" })
    thematic_id = res.data['createThematic']['thematic']['id']
    return thematic_id
开发者ID:assembl,项目名称:assembl,代码行数:34,代码来源:graphql.py

示例9: test_query_landing_page_module_types

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_query_landing_page_module_types(graphql_request):
    query = u"""query LandingPageModuleTypes($lang: String!) {
        landingPageModuleTypes {
            titleEntries {
                localeCode
                value
            }
            title(lang: $lang)
            defaultOrder
            editableOrder
            identifier
            required
        }
    }
    """
    res = schema.execute(
        query,
        context_value=graphql_request,
        variable_values={"lang": u"en"})
    assert res.errors is None
    assert len(res.data['landingPageModuleTypes']) == MODULES_COUNT
    for module_type in res.data['landingPageModuleTypes']:
        if module_type['identifier'] == 'INTRODUCTION':
            assert module_type['title'] == u'Text & Multimedia'
            assert module_type['defaultOrder'] == 2.0
            assert module_type['editableOrder'] is True
            assert module_type['required'] is False
开发者ID:assembl,项目名称:assembl,代码行数:29,代码来源:test_graphql_landing_page.py

示例10: test_query_vote_session_proposals

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_query_vote_session_proposals(graphql_request, timeline_vote_session, vote_session, vote_proposal, graphql_registry):

    query = graphql_registry['VoteSession']
    res = schema.execute(query, context_value=graphql_request, variable_values={
        "ideaId": to_global_id('Idea', vote_session.idea_id),
        "lang": "en"
    })
    assert res.errors is None
    proposal_id = to_global_id("Idea", vote_proposal.id)
    assert json.loads(json.dumps(res.data['voteSession']['proposals'])) == [{
        u'id': proposal_id,
        u'order': 1.0,
        u'title': u'Understanding the dynamics and issues',
        u'description': u'Description: Understanding the dynamics and issues',
        u'titleEntries': [
            {u'localeCode': u'en',
             u'value': u'Understanding the dynamics and issues'},
            {u'localeCode': u'fr',
             u'value': u'Comprendre les dynamiques et les enjeux'}],
        u'descriptionEntries': [
            {u'localeCode': u'en',
              u'value': u'Description: Understanding the dynamics and issues'},
            {u'localeCode': u'fr',
              u'value': u'Description: Comprendre les dynamiques et les enjeux'}],
        u'modules': [],
        u'voteResults': {u'numParticipants': 0, u'participants': []}
        }]
开发者ID:assembl,项目名称:assembl,代码行数:29,代码来源:test_graphql_vote_session.py

示例11: test_graphql_get_profile

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_graphql_get_profile(graphql_request, participant1_user):
    res = schema.execute(u"""
query User($id: ID!) {
    user: node(id: $id) {
      ... on AgentProfile {
        id
        name
        username
        displayName
        email
        creationDate
        image { externalUrl }
        hasPassword
      }
    }
  }
""", context_value=graphql_request, variable_values={
        "id": to_global_id('AgentProfile', participant1_user.id)
    })
    assert res.errors is None
    assert res.data['user']['name'] == u'A. Barking Loon'
    assert res.data['user']['username'] is None
    assert res.data['user']['displayName'] == u'A. Barking Loon'
    assert res.data['user']['email'] == u'[email protected]'
    # 2018-01-04T12:08:44.735489+00:00
    assert u'T' in res.data['user']['creationDate']
    assert res.data['user']['image'] is None
    assert res.data['user']['hasPassword']
开发者ID:assembl,项目名称:assembl,代码行数:30,代码来源:test_graphql_user.py

示例12: test_query_resources

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_query_resources(graphql_registry, discussion, resource, resource_with_image_and_doc, graphql_request):
    res = schema.execute(
        graphql_registry['ResourcesQuery'],
        variable_values={
            "lang": u"en"
        },
        context_value=graphql_request)
    assert res.data['resources'][0]['order'] == 1.0
    assert res.data['resources'][1]['order'] == 2.0

    first_resource = res.data['resources'][0]
    second_resource = res.data['resources'][1]

    assert first_resource['title'] == u'another resource'
    assert second_resource['title'] == u'a resource'

    assert second_resource['text'] == u'Lorem ipsum dolor sit amet'
    assert second_resource['embedCode'] == u'<iframe ...>'
    assert second_resource['doc'] == None
    assert second_resource['image'] == None

    assert '/documents/' in first_resource['image']['externalUrl']
    assert '/documents/' in first_resource['doc']['externalUrl']
    # this is the title of the File object, not the title of the ResourceAttachment object
    assert first_resource['doc']['title'] == "mydocument.pdf"
开发者ID:assembl,项目名称:assembl,代码行数:27,代码来源:test_graphql_resources_center.py

示例13: test_graphql_get_synthesis

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_graphql_get_synthesis(graphql_request,
                               user_language_preference_en_cookie,
                               synthesis_in_syntheses):
    synthesis_id = synthesis_in_syntheses.data['syntheses'][0]['id']
    res = schema.execute(
        u"""query SynthesisQuery($id: ID!, $lang: String) {
            synthesis: node(id: $id) {
              ... on Synthesis {
                id
                subject(lang: $lang)
                ideas {
                  ... on Idea {
                    id
                    live {
                      ... on Idea {
                        id
                        img { externalUrl }
                      }
                    }
                  }
                }
              }
            }
          }
        """,
        context_value=graphql_request,
        variable_values={
             "id": synthesis_id,
            "lang": "en"
        })
    assert len(res.data) == 1
    synthesis = res.data['synthesis']
    assert synthesis['subject'] == 'subject EN'
    assert len(synthesis['ideas']) == 2
开发者ID:assembl,项目名称:assembl,代码行数:36,代码来源:test_graphql_syntheses.py

示例14: number_gauge_vote_specification_associated_to_proposal

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def number_gauge_vote_specification_associated_to_proposal(request, test_session, discussion, graphql_request, vote_session, number_gauge_vote_specification, vote_proposal, graphql_registry):
    mutation = graphql_registry['createNumberGaugeVoteSpecification']
    vote_session_id = to_global_id("VoteSession", vote_session.id)
    proposal_id = to_global_id("Idea", vote_proposal.id)
    template_gauge_vote_spec_id = to_global_id("NumberGaugeVoteSpecification", number_gauge_vote_specification.id)
    from assembl.graphql.schema import Schema as schema
    res = schema.execute(mutation, context_value=graphql_request, variable_values={
        "voteSessionId": vote_session_id,
        "proposalId": proposal_id,
        "voteSpecTemplateId": template_gauge_vote_spec_id,
        "titleEntries": [
            {"value": u"Comprendre les dynamiques et les enjeux", "localeCode": "fr"},
            {"value": u"Understanding the dynamics and issues", "localeCode": "en"}
        ],
        "instructionsEntries":
        [
            {"value": u"Instructions : Comprendre les dynamiques et les enjeux", "localeCode": "fr"},
            {"value": u"Instructions: Understanding the dynamics and issues", "localeCode": "en"}
        ],
        "isCustom": True,
        "minimum": 0.0,
        "maximum": 60.0,
        "nbTicks": 7,
        "unit": u"M€"
    })
    assert res.errors is None
    vote_spec = vote_session.vote_specifications[-1]

    def fin():
        print "finalizer number_gauge_vote_specification_associated_to_proposal"
        test_session.delete(vote_spec)
        test_session.flush()

    request.addfinalizer(fin)
    return vote_spec
开发者ID:assembl,项目名称:assembl,代码行数:37,代码来源:vote_session.py

示例15: test_mutation_confirm_extract

# 需要导入模块: from assembl.graphql.schema import Schema [as 别名]
# 或者: from assembl.graphql.schema.Schema import execute [as 别名]
def test_mutation_confirm_extract(graphql_request, extract_with_range_submitted_in_reply_post_1):
  from assembl.models import ExtractStates
  state = extract_with_range_submitted_in_reply_post_1.extract_state
  assert ExtractStates.SUBMITTED.value == state
  extract_graphql_db_id = to_global_id('Extract',extract_with_range_submitted_in_reply_post_1.id)

  variable_values = {
    "extractId": extract_graphql_db_id
  }

  res = schema.execute(u"""
mutation confirmExtract($extractId: ID!) {
  confirmExtract(extractId: $extractId) {
    success
  }
}
""", context_value=graphql_request, variable_values=variable_values)

  assert json.loads(json.dumps(res.data)) == {
    u'confirmExtract': {
      u'success': True
    }
  }
  state = extract_with_range_submitted_in_reply_post_1.extract_state
  assert ExtractStates.PUBLISHED.value == state
开发者ID:assembl,项目名称:assembl,代码行数:27,代码来源:test_graphql_extracts.py


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