def test_without_path_order(client, submitter, pg_driver_clean, cgci_blgsp): """Assert that the ordering is applied after the exception""" put_example_entities_together(client, pg_driver_clean, submitter) utils.put_entity_from_file(client, 'case.json', submitter) utils.put_entity_from_file(client, 'sample.json', submitter) with pg_driver_clean.session_scope(): c = pg_driver_clean.nodes(models.Case).one() c.samples = [] r = client.post(path, headers=submitter, data=json.dumps({ 'query': """ query Test { case ( order_by_desc: "created_datetime", without_path_to: { type: "sample" }) { submitter_id } }""" })) assert r.json == { "data": { "case": [{ "submitter_id": "BLGSP-71-06-00019" }] } }, r.data
def test_filter_empty_prop_list(client, submitter, pg_driver_clean, cgci_blgsp, monkeypatch): post_example_entities_together(client, pg_driver_clean, submitter) utils.put_entity_from_file(client, 'read_group.json', submitter) utils.patch_indexclient(monkeypatch) utils.put_entity_from_file(client, 'submitted_unaligned_reads.json', submitter) r = client.post(path, headers=submitter, data=json.dumps({ 'query': """{ a: _case_count(submitter_id: []) b: _submitted_unaligned_reads_count c: _submitted_unaligned_reads_count(file_state: []) }""" })) assert r.json == { 'data': { 'a': 1, 'b': 1, 'c': 1, } }
def test_transaction_log_entities_errors(client, submitter, pg_driver_clean, cgci_blgsp): utils.reset_transactions(pg_driver_clean) post_example_entities_together(client, pg_driver_clean, 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") # using response 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, data=json.dumps({"query": query})) assert r.status_code == 200 error = r.json["data"]["log"][0]["doc"][0]["resp"]["ent"][0]["err"][0] # using response_json query = """ {{ log: transaction_log( id: {} ) {{ doc: documents {{ resp: response_json }} }} }} """ query = query.format(transaction_id) r = client.post(path, headers=submitter, data=json.dumps({"query": query})) assert r.status_code == 200 resp = json.loads(r.json["data"]["log"][0]["doc"][0]["resp"]) error = resp["entities"][0]["errors"][0] assert all(key in error for key in ("type", "keys", "message"))
def test_submitted_unaligned_reads_with_path_to_read_group( client, submitter, pg_driver_clean, cgci_blgsp): """Regression for incorrect counts""" post_example_entities_together(client, pg_driver_clean, submitter) utils.put_entity_from_file(client, 'read_group.json', submitter) files = [ models.SubmittedUnalignedReads('file_{}'.format(i), project_id='CGCI-BLGSP') for i in range(3) ] with pg_driver_clean.session_scope() as s: rg = pg_driver_clean.nodes(models.ReadGroup).one() rg.submitted_unaligned_reads_files = files rg = s.merge(rg) r = client.post(path, headers=submitter, data=json.dumps({ 'query': """{ read_group(id: "%s") { id _submitted_unaligned_reads_files_count } submitted_unaligned_reads(with_path_to:{type: "read_group"}) { id } }""" % rg.node_id })) assert r.json == { "data": { "read_group": [{ "_submitted_unaligned_reads_files_count": 3, "id": rg.node_id }], "submitted_unaligned_reads": [{ "id": "file_0" }, { "id": "file_1" }, { "id": "file_2" }] } }
def test_read_group_with_path_to_case(client, submitter, pg_driver_clean, cgci_blgsp): """Regression for incorrect counts""" put_example_entities_together(client, pg_driver_clean, submitter) utils.put_entity_from_file(client, 'read_group.json', submitter) data = json.dumps({ 'query': """ { _read_group_count (with_path_to: {type: "case"}) } """, }) r = client.post(path, headers=submitter, data=data) assert r.json == { "data": { "_read_group_count": 1, } }
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'))