Skip to content

Commit

Permalink
Merge pull request #85 from ecmwf-projects/COPDS-1346-refactor-client…
Browse files Browse the repository at this point in the history
…-job

Update get_qos_status_from_request
  • Loading branch information
mcucchi9 authored Oct 23, 2023
2 parents 77b1fa2 + 9f7f9d2 commit 3e0fd19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cads_broker/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SystemRequest(BaseModel):

# joined is temporary
cache_entry = sa.orm.relationship(cacholote.database.CacheEntry, lazy="joined")
adaptor_properties = sa.orm.relationship(AdaptorProperties, lazy="joined")
adaptor_properties = sa.orm.relationship(AdaptorProperties, lazy="select")

@property
def age(self):
Expand Down Expand Up @@ -308,10 +308,10 @@ def count_users(status: str, entry_point: str, session: sa.orm.Session) -> int:


def get_qos_status_from_request(
request: dict[str, Any]
request: SystemRequest,
) -> dict[str, list[tuple[str, str]]]:
ret_value: dict[str, list[str]] = {}
for rule_name, rules in request["qos_status"].items():
for rule_name, rules in request.qos_status.items():
ret_value[rule_name] = []
for rule in rules.values():
ret_value[rule_name].append(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_02_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def test_set_request_qos_rule(session_obj: sa.orm.sessionmaker) -> None:


def test_get_qos_status_from_request() -> None:
test_request = {
test_qos_status = {
"qos_status": {
"rule_name_1": {
"rule_key_1_1": {
Expand All @@ -538,6 +538,7 @@ def test_get_qos_status_from_request() -> None:
"rule_name_2": {"rule_key_2_1": {}},
}
}
test_request = db.SystemRequest(**test_qos_status)
exp_qos_status = {
"rule_name_1": [("info_1_1", "conclusion_1_1"), ("info_1_2", "conclusion_1_2")],
"rule_name_2": [("", "")],
Expand Down

0 comments on commit 3e0fd19

Please sign in to comment.