From fdfeb268e352210de3586be0c693de0fd531a96d Mon Sep 17 00:00:00 2001 From: "Julien M." Date: Thu, 18 Jul 2024 22:07:46 +0200 Subject: [PATCH] enhance: add quick and dirty tests --- dicogis/models/database_connection.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dicogis/models/database_connection.py b/dicogis/models/database_connection.py index 335aec20..3a68f8db 100644 --- a/dicogis/models/database_connection.py +++ b/dicogis/models/database_connection.py @@ -136,3 +136,26 @@ def store_in_pgservice_file(self) -> tuple[bool, str]: ) logger.error(err_msg, stack_info=True) return False, err_msg + + +if __name__ == "__main__": + db = DatabaseConnection(service_name="empty") + print(db.connection_params_as_dict, bool(db.connection_params_as_dict)) + db.store_in_pgservice_file() + + db = DatabaseConnection(service_name="minimal", host="localhost") + print(db.connection_params_as_dict, bool(db.connection_params_as_dict)) + db.store_in_pgservice_file() + + pgserviceparser.remove_service("minimal") + + new_srv_settings = { + "host": "localhost", + "dbname": "best_database_ever", + "port": 5432, + "user": "ro_gis_user", + } + new_srv = pgserviceparser.write_service( + service_name="gis_prod_ro", settings=new_srv_settings, add_if_not_exists=True + ) + assert isinstance(new_srv, dict)