99import requests
1010import yaml
1111from pytest_operator .plugin import OpsTest
12- from tenacity import retry , retry_if_result , wait_exponential , stop_after_attempt
12+ from tenacity import retry , retry_if_result , stop_after_attempt , wait_exponential
1313
1414METADATA = yaml .safe_load (Path ("./metadata.yaml" ).read_text ())
1515DATABASE_APP_NAME = METADATA ["name" ]
1616
1717
1818async def check_database_users_existence (
19- ops_test : OpsTest ,
20- users_that_should_exist : List [str ],
21- users_that_should_not_exist : List [str ],
22- admin : bool = False ,
19+ ops_test : OpsTest ,
20+ users_that_should_exist : List [str ],
21+ users_that_should_not_exist : List [str ],
22+ admin : bool = False ,
2323) -> None :
2424 """Checks that applications users exist in the database.
2525
@@ -116,12 +116,12 @@ def convert_records_to_dict(records: List[tuple]) -> dict:
116116
117117
118118async def deploy_and_relate_application_with_postgresql (
119- ops_test : OpsTest ,
120- charm : str ,
121- application_name : str ,
122- number_of_units : int ,
123- channel : str = "stable" ,
124- relation : str = "db" ,
119+ ops_test : OpsTest ,
120+ charm : str ,
121+ application_name : str ,
122+ number_of_units : int ,
123+ channel : str = "stable" ,
124+ relation : str = "db" ,
125125) -> int :
126126 """Helper function to deploy and relate application with PostgreSQL.
127127
@@ -166,10 +166,10 @@ async def deploy_and_relate_application_with_postgresql(
166166
167167
168168async def execute_query_on_unit (
169- unit_address : str ,
170- password : str ,
171- query : str ,
172- database : str = "postgres" ,
169+ unit_address : str ,
170+ password : str ,
171+ query : str ,
172+ database : str = "postgres" ,
173173):
174174 """Execute given PostgreSQL query on a unit.
175175
@@ -183,7 +183,7 @@ async def execute_query_on_unit(
183183 A list of rows that were potentially returned from the query.
184184 """
185185 with psycopg2 .connect (
186- f"dbname='{ database } ' user='operator' host='{ unit_address } ' password='{ password } ' connect_timeout=10"
186+ f"dbname='{ database } ' user='operator' host='{ unit_address } ' password='{ password } ' connect_timeout=10"
187187 ) as connection , connection .cursor () as cursor :
188188 cursor .execute (query )
189189 output = list (itertools .chain (* cursor .fetchall ()))
0 commit comments