Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit f840fed

Browse files
authored
fix: Indication range from int -> float (#800)
1 parent a9526b8 commit f840fed

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

graphql_api/tests/test_repository.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,36 @@ def test_repository_repository_config_indication_range(self, mocked_useryaml):
403403
== 80
404404
)
405405

406+
@patch("shared.yaml.user_yaml.UserYaml.get_final_yaml")
407+
def test_repository_repository_config_indication_range_float(self, mocked_useryaml):
408+
mocked_useryaml.return_value = {"coverage": {"range": [61.1, 82.2]}}
409+
410+
repo = RepositoryFactory(
411+
author=self.owner,
412+
active=True,
413+
private=True,
414+
)
415+
416+
data = self.gql_request(
417+
query_repository
418+
% "repositoryConfig { indicationRange { upperRange lowerRange } }",
419+
owner=self.owner,
420+
variables={"name": repo.name},
421+
)
422+
423+
assert (
424+
data["me"]["owner"]["repository"]["repositoryConfig"]["indicationRange"][
425+
"lowerRange"
426+
]
427+
== 61.1
428+
)
429+
assert (
430+
data["me"]["owner"]["repository"]["repositoryConfig"]["indicationRange"][
431+
"upperRange"
432+
]
433+
== 82.2
434+
)
435+
406436
@patch("services.activation.try_auto_activate")
407437
def test_repository_auto_activate(self, try_auto_activate):
408438
repo = RepositoryFactory(

graphql_api/types/repository_config/repository_config.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ type RepositoryConfig {
33
}
44

55
type IndicationRange {
6-
upperRange: Int!
7-
lowerRange: Int!
6+
upperRange: Float!
7+
lowerRange: Float!
88
}

graphql_api/types/repository_config/repository_config.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,30 @@
1212

1313

1414
class IndicationRange(TypedDict):
15-
lowerRange: str
16-
upperRange: str
15+
lowerRange: float
16+
upperRange: float
1717

1818

1919
@repository_config_bindable.field("indicationRange")
20-
async def resolve_indication_range(repository: Repository, info) -> dict[str, int]:
20+
async def resolve_indication_range(repository: Repository, info) -> dict[str, float]:
2121
owner = await OwnerLoader.loader(info).load(repository.author_id)
2222

2323
yaml = await sync_to_async(UserYaml.get_final_yaml)(
2424
owner_yaml=owner.yaml, repo_yaml=repository.yaml
2525
)
26-
range: list[int] = yaml.get("coverage", {"range": [60, 80]}).get("range", [60, 80])
26+
range: list[float] = yaml.get("coverage", {"range": [60, 80]}).get(
27+
"range", [60, 80]
28+
)
2729
return {"lowerRange": range[0], "upperRange": range[1]}
2830

2931

3032
@indication_range_bindable.field("upperRange")
31-
def resolve_upper_range(indicationRange: IndicationRange, info) -> int:
33+
def resolve_upper_range(indicationRange: IndicationRange, info) -> float:
3234
upperRange = indicationRange.get("upperRange")
3335
return upperRange
3436

3537

3638
@indication_range_bindable.field("lowerRange")
37-
def resolve_lower_range(indicationRange: IndicationRange, info) -> int:
39+
def resolve_lower_range(indicationRange: IndicationRange, info) -> float:
3840
lowerRange = indicationRange.get("lowerRange")
3941
return lowerRange

0 commit comments

Comments
 (0)