Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix long type for big numbers #201

Merged
merged 6 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions peregrine/resources/submission/graphql/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def lookup_graphql_type(T):
return {
bool: graphene.Boolean,
float: graphene.Float,
int: graphene.Int,
int: graphene.Float,
thanh-nguyen-dang marked this conversation as resolved.
Show resolved Hide resolved
thanh-nguyen-dang marked this conversation as resolved.
Show resolved Hide resolved
list: graphene.List(graphene.String),
}.get(T, graphene.String)

Expand Down Expand Up @@ -580,7 +580,7 @@ def get_node_interface_args():
of_type=graphene.List(graphene.String),
project_id=graphene.String(),
category=graphene.String(),
)
),
)


Expand Down Expand Up @@ -990,7 +990,7 @@ def get_withpathto_type():
for cls in psqlgraph.Node.get_subclasses()
]
for k, v in cls_attrs.items()
}
},
),
)

Expand Down
4 changes: 2 additions & 2 deletions tests/graphql/data/bulk1.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"doc_format": "JSON"
},
{
"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\"}",
"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\"}",
"name": "CGCI-file-1.json",
"doc_format": "JSON"
},
{
"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\"}",
"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\"}",
"name": "CGCI-file-2.json",
"doc_format": "JSON"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/graphql/data/read_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"library_strategy": "WXS",
"library_name": "library1",
"is_paired_end": false,
"read_length": 12345,
"read_length": 59627182820,
"read_group_name": "readgroup-1"
}
2 changes: 1 addition & 1 deletion tests/graphql/data/submitted_unaligned_reads.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"submitter_id": "CGCI-file-2",
"data_format": "BAM",
"file_size": 5962718282,
"file_size": 59627182820,
"file_name": "C500.CGCI-file1.bam",
"md5sum": "35b39360cc41a7b635980159aef265ba",
"experimental_strategy": "WGS",
Expand Down
29 changes: 29 additions & 0 deletions tests/graphql/test_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,35 @@ def test_without_path_order(client, submitter, pg_driver_clean, cgci_blgsp):
}, r.data


def test_long_as_float_type(client, submitter, pg_driver_clean, cgci_blgsp):
"""Assert the long type is working as float"""
post_example_entities_together(client, pg_driver_clean, submitter)

r = client.post(
path,
headers=submitter,
data=json.dumps(
{
"query": """
query Test {
read_group (
order_by_desc: "read_length",
)
{ submitter_id, read_length }
}
"""
}
),
)
assert r.json == {
"data": {
"read_group": [
{"submitter_id": "test-readgroup-1", "read_length": 59627182820.0},
]
}
}, r.data


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)
Expand Down
1 change: 1 addition & 0 deletions tests/graphql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"diagnosis.json",
"exposure.json",
"treatment.json",
"read_group.json",
]

PATH = "/v0/submission/graphql"
Expand Down