Skip to content

Commit 23425c4

Browse files
Fix long type for big numbers (#201)
* fix(long): change int to float
1 parent 1bf2dc4 commit 23425c4

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
lines changed

peregrine/resources/submission/graphql/node.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def lookup_graphql_type(T):
525525
return {
526526
bool: graphene.Boolean,
527527
float: graphene.Float,
528-
int: graphene.Int,
528+
int: graphene.Float,
529529
list: graphene.List(graphene.String),
530530
}.get(T, graphene.String)
531531

@@ -580,7 +580,7 @@ def get_node_interface_args():
580580
of_type=graphene.List(graphene.String),
581581
project_id=graphene.String(),
582582
category=graphene.String(),
583-
)
583+
),
584584
)
585585

586586

@@ -990,7 +990,7 @@ def get_withpathto_type():
990990
for cls in psqlgraph.Node.get_subclasses()
991991
]
992992
for k, v in cls_attrs.items()
993-
}
993+
},
994994
),
995995
)
996996

tests/graphql/data/bulk1.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
"doc_format": "JSON"
3131
},
3232
{
33-
"doc": "{\"file_name\": \"C500.CGCI-file1.bam\", \"md5sum\": \"35b39360cc41a7b635980159aef265ba\", \"submitter_id\": \"CGCI-file-1\", \"aliquots\": {\"submitter_id\": \"BLGSP-71-06-00005-99A-01D\"}, \"file_size\": 5962718282, \"type\": \"file\"}",
33+
"doc": "{\"file_name\": \"C500.CGCI-file1.bam\", \"md5sum\": \"35b39360cc41a7b635980159aef265ba\", \"submitter_id\": \"CGCI-file-1\", \"aliquots\": {\"submitter_id\": \"BLGSP-71-06-00005-99A-01D\"}, \"file_size\": 5962718282, \"type\": \"file\"}",
3434
"name": "CGCI-file-1.json",
3535
"doc_format": "JSON"
3636
},
3737
{
38-
"doc": "{\"file_name\": \"C500.CGCI-file2.bam\", \"md5sum\": \"35980159aef265ba35b39360cc41a7b6\", \"submitter_id\": \"CGCI-file-2\", \"aliquots\": {\"submitter_id\": \"BLGSP-71-06-00005-99A-01D\"}, \"file_size\": 5962718282, \"type\": \"file\"}",
38+
"doc": "{\"file_name\": \"C500.CGCI-file2.bam\", \"md5sum\": \"35980159aef265ba35b39360cc41a7b6\", \"submitter_id\": \"CGCI-file-2\", \"aliquots\": {\"submitter_id\": \"BLGSP-71-06-00005-99A-01D\"}, \"file_size\": 5962718282, \"type\": \"file\"}",
3939
"name": "CGCI-file-2.json",
4040
"doc_format": "JSON"
4141
},

tests/graphql/data/read_group.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"library_strategy": "WXS",
1111
"library_name": "library1",
1212
"is_paired_end": false,
13-
"read_length": 12345,
13+
"read_length": 59627182820,
1414
"read_group_name": "readgroup-1"
1515
}

tests/graphql/data/submitted_unaligned_reads.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"submitter_id": "CGCI-file-2",
77
"data_format": "BAM",
8-
"file_size": 5962718282,
8+
"file_size": 59627182820,
99
"file_name": "C500.CGCI-file1.bam",
1010
"md5sum": "35b39360cc41a7b635980159aef265ba",
1111
"experimental_strategy": "WGS",

tests/graphql/test_graphql.py

+29
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,35 @@ def test_without_path_order(client, submitter, pg_driver_clean, cgci_blgsp):
12701270
}, r.data
12711271

12721272

1273+
def test_long_as_float_type(client, submitter, pg_driver_clean, cgci_blgsp):
1274+
"""Assert the long type is working as float"""
1275+
post_example_entities_together(client, pg_driver_clean, submitter)
1276+
1277+
r = client.post(
1278+
path,
1279+
headers=submitter,
1280+
data=json.dumps(
1281+
{
1282+
"query": """
1283+
query Test {
1284+
read_group (
1285+
order_by_desc: "read_length",
1286+
)
1287+
{ submitter_id, read_length }
1288+
}
1289+
"""
1290+
}
1291+
),
1292+
)
1293+
assert r.json == {
1294+
"data": {
1295+
"read_group": [
1296+
{"submitter_id": "test-readgroup-1", "read_length": 59627182820.0},
1297+
]
1298+
}
1299+
}, r.data
1300+
1301+
12731302
def test_read_group_with_path_to_case(client, submitter, pg_driver_clean, cgci_blgsp):
12741303
"""Regression for incorrect counts"""
12751304
put_example_entities_together(client, pg_driver_clean, submitter)

tests/graphql/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"diagnosis.json",
2626
"exposure.json",
2727
"treatment.json",
28+
"read_group.json",
2829
]
2930

3031
PATH = "/v0/submission/graphql"

0 commit comments

Comments
 (0)