コード例 #1
0
def test_transaction_log_related_cases_filter(client, submitter, pg_driver,
                                              cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    data = json.dumps({
        'query':
        """
            {a: transaction_log (first: 1) { related_cases { id }}}
        """
    })
    r = client.post(path, headers=submitter(path, 'post'), data=data)
    assert r.status_code == 200
    print r.data
    case_id = r.json['data']['a'][0]['related_cases'][0]['id']
    data = json.dumps({
        'query': """
            query Test($caseId: String) {
                a: transaction_log (related_cases: [$caseId]) {
                    related_cases { id submitter_id }
                }
            }
        """,
        "variables": {
            "caseId": case_id
        },
    })
    r = client.post(path, headers=submitter(path, 'post'), data=data)
    assert r.status_code == 200
    print r.data
    related_case_doc = r.json['data']['a'][0]['related_cases'][0]
    assert related_case_doc['id'] == case_id
    assert related_case_doc['submitter_id']
コード例 #2
0
def test_transaction_logs_quick_search(client, submitter, pg_driver,
                                       cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    with pg_driver.session_scope():
        id_ = str(pg_driver.nodes(models.submission.TransactionLog).first().id)
    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps({
                        'query':
                        """{
          a: transaction_log (quick_search: "%s") { id }
          b: transaction_log (quick_search: %s)   { id }
          c: transaction_log (quick_search: "A") { id }
        }""" % (id_, id_)
                    }))
    assert r.json == {
        'data': {
            'a': [{
                'id': id_
            }],
            'b': [{
                'id': id_
            }],
            'c': [],
        }
    }, r.data
コード例 #3
0
def test_transaction_log_documents(client, submitter, pg_driver, cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps({
                        'query':
                        """{ log: transaction_log {
        doc: documents { doc_size name }}}"""
                    }))
    print r.data
    doc = r.json['data']['log'][0]['doc'][0]
    assert doc['name'] is None
    assert isinstance(doc['doc_size'], int)
コード例 #4
0
def test_transaction_log_entities(client, submitter, pg_driver, cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps({
                        'query':
                        """{ log: transaction_log {
        doc: documents { resp: response { ent: entities { type }}}}}"""
                    }))
    print r.data
    assert r.status_code == 200
    entities = r.json['data']['log'][0]['doc'][0]['resp']['ent']
    assert all(e['type'] for e in entities)
コード例 #5
0
def test_transaction_log_type(client, submitter, pg_driver, cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps(
                        {'query': """{ a: transaction_log { role type }}"""}))
    print r.data
    type_ = graphql.transaction.TransactionLog.TYPE_MAP['create']
    assert r.json['data']['a'][0]['type'] == type_
    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps({
                        'query':
                        """{
        a: transaction_log(type: "%s") { role type }
        }""" % type_
                    }))
    print r.data
    assert r.json['data']['a']
コード例 #6
0
def test_transaction_logs_order_desc(client, submitter, pg_driver, cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    with pg_driver.session_scope():
        assert pg_driver.nodes(models.submission.TransactionLog).count() == 1
    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps({
                        'query':
                        """{
          a: transaction_log (order_by_desc: "id") {
            id
            project_id
            created_datetime
          }
        }"""
                    }))
    print r.data
    _original = r.json['data']['a']
    _sorted = sorted(_original, cmp=(lambda a, b: cmp(b['id'], a['id'])))
    assert _original == _sorted, r.data
コード例 #7
0
def test_transaction_log_entities_errors(client, submitter, pg_driver,
                                         cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    put_response = utils.put_entity_from_file(client,
                                              'read_group_invalid.json',
                                              submitter=submitter,
                                              validate=False)
    transaction_id = put_response.json.get('transaction_id')
    query = """
    {{ log: transaction_log( id: {} ) {{
        doc: documents {{ resp: response {{ ent: entities {{
        err: errors {{ type keys message }} }} }} }} }} }}
    """
    query = query.format(transaction_id)
    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps({'query': query}))
    assert r.status_code == 200
    error = r.json['data']['log'][0]['doc'][0]['resp']['ent'][0]['err'][0]
    assert all(key in error for key in ('type', 'keys', 'message'))
コード例 #8
0
def test_transaction_log_related_cases(client, submitter, pg_driver,
                                       cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)

    r = client.post(path,
                    headers=submitter(path, 'post'),
                    data=json.dumps({
                        'query':
                        """
        query Test {
          a: transaction_log (first: 1) {
            type documents {response { entities {related_cases {
              id submitter_id
            }}}}}
        }"""
                    }))
    assert r.status_code == 200
    print(r.data)
    related_case = (r.json['data']['a'][0]['documents'][0]['response']
                    ['entities'][1]['related_cases'][0])
    assert 'submitter_id' in related_case
    assert 'id' in related_case
コード例 #9
0
def test_transaction_logs(client, submitter, pg_driver, cgci_blgsp):
    utils.reset_transactions(pg_driver)
    post_example_entities_together(client, pg_driver, submitter)
    with pg_driver.session_scope():
        assert pg_driver.nodes(models.submission.TransactionLog).count() == 1