project: ruff check and format
This commit is contained in:
parent
0a9d941eea
commit
1e906fc3f0
27 changed files with 93 additions and 63 deletions
|
|
@ -2,4 +2,4 @@
|
|||
Configurations for the <this> module
|
||||
|
||||
Exports:
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
Constants for the <this> module
|
||||
|
||||
Exports:
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ Dependencies related to the <this> module
|
|||
|
||||
Exports:
|
||||
- <dep_name>: <return_type>: <description>
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@ Exceptions related to the <this> modules
|
|||
|
||||
Exceptions:
|
||||
- <ExceptionName>: Details e.g. optional params
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ Models:
|
|||
- <normal_columns[FK][PK]>
|
||||
- <orm_relationships>
|
||||
- <calculated_properties>
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ Exports:
|
|||
- Dependencies should be used for db model get and validation where possible
|
||||
- Verify module level docstring is still accurate after updates
|
||||
"""
|
||||
|
||||
import threading
|
||||
from typing import Annotated, Optional
|
||||
|
||||
|
|
@ -38,14 +39,16 @@ async def start_timer(request: Request, interval: int):
|
|||
print("ping")
|
||||
|
||||
stop_event = threading.Event()
|
||||
timer = create_timer(func=example_timer_target, interval=interval, stop_event=stop_event)
|
||||
timer = create_timer(
|
||||
func=example_timer_target, interval=interval, stop_event=stop_event
|
||||
)
|
||||
timer_ident = "example_timer"
|
||||
|
||||
timer_tracker = {
|
||||
"ident": timer_ident,
|
||||
"interval": interval,
|
||||
"stop_event": stop_event,
|
||||
"timer": timer
|
||||
"timer": timer,
|
||||
}
|
||||
timer.start()
|
||||
|
||||
|
|
@ -58,7 +61,10 @@ async def start_timer(request: Request, interval: int):
|
|||
async def stop_timer(request: Request, ident: str):
|
||||
timers = request.app.state.timers
|
||||
|
||||
idx, timer_tracker = next(((i, timer) for i, timer in enumerate(timers) if timer["ident"] == ident), (None, None))
|
||||
idx, timer_tracker = next(
|
||||
((i, timer) for i, timer in enumerate(timers) if timer["ident"] == ident),
|
||||
(None, None),
|
||||
)
|
||||
|
||||
if not timer_tracker:
|
||||
raise HTTPException(status_code=404, detail="Timer not found")
|
||||
|
|
@ -72,9 +78,14 @@ async def stop_timer(request: Request, ident: str):
|
|||
|
||||
|
||||
@router.get("/hub/access")
|
||||
async def test_hub_access(headers: header_dependency, client: http_client_dependency, org_name: Annotated[str, Query()],
|
||||
resource_name: Annotated[str, Query()] = "example_resource",
|
||||
action: Annotated[str, Query()] = "read", instance: Optional[Annotated[str, Query()]] = None):
|
||||
async def test_hub_access(
|
||||
headers: header_dependency,
|
||||
client: http_client_dependency,
|
||||
org_name: Annotated[str, Query()],
|
||||
resource_name: Annotated[str, Query()] = "example_resource",
|
||||
action: Annotated[str, Query()] = "read",
|
||||
instance: Optional[Annotated[str, Query()]] = None,
|
||||
):
|
||||
rn = generate_resource_name(resource=resource_name, org=org_name, instance=instance)
|
||||
|
||||
request_body = {
|
||||
|
|
@ -83,33 +94,28 @@ async def test_hub_access(headers: header_dependency, client: http_client_depend
|
|||
}
|
||||
|
||||
hub_response = await client.post(
|
||||
f"http://localhost:8001/api/v1/iam/can_act_on_resource",
|
||||
"http://localhost:8001/api/v1/iam/can_act_on_resource",
|
||||
headers=headers,
|
||||
json=request_body
|
||||
json=request_body,
|
||||
)
|
||||
|
||||
response = {
|
||||
"response": {
|
||||
"status": hub_response.status_code,
|
||||
"json": hub_response.json()
|
||||
}
|
||||
"response": {"status": hub_response.status_code, "json": hub_response.json()}
|
||||
}
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@router.get("/hub/user")
|
||||
async def test_hub_user_details(headers: header_dependency, client: http_client_dependency):
|
||||
async def test_hub_user_details(
|
||||
headers: header_dependency, client: http_client_dependency
|
||||
):
|
||||
hub_response = await client.get(
|
||||
f"http://localhost:8001/api/v1/user/self/db",
|
||||
headers=headers
|
||||
"http://localhost:8001/api/v1/user/self/db", headers=headers
|
||||
)
|
||||
|
||||
response = {
|
||||
"response": {
|
||||
"status": hub_response.status_code,
|
||||
"json": hub_response.json()
|
||||
}
|
||||
"response": {"status": hub_response.status_code, "json": hub_response.json()}
|
||||
}
|
||||
|
||||
return response
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ Models follow the nomenclature of:
|
|||
- Sub-models: "<Resource><Opt:>Schema"
|
||||
- Mixins: "<Attribute>Mixin"
|
||||
- Models: "<Module><Method><Resource><Opt:Resource><Direction>" ie ""
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
Module specific business logic for the <this> module
|
||||
|
||||
Exports:
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
"""
|
||||
Non-business logic reusable functions and classes for the <this> module
|
||||
"""
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue