From 0e14a4d4ff8bc6f6a2b9364d801d405fffdbd3a0 Mon Sep 17 00:00:00 2001 From: Mohammad Torkashvand <mohammad.torkashvand@geant.org> Date: Mon, 18 Mar 2024 15:04:44 +0100 Subject: [PATCH] regnerated the PartnerTable migration again --- example.csv | 5 ----- gso/cli/imports.py | 6 ++---- gso/services/partners.py | 4 ---- test/fixtures.py | 3 ++- 4 files changed, 4 insertions(+), 14 deletions(-) delete mode 100644 example.csv diff --git a/example.csv b/example.csv deleted file mode 100644 index 8b7a5d92..00000000 --- a/example.csv +++ /dev/null @@ -1,5 +0,0 @@ -name,email,as_number,as_set,route_set,black_listed_as_sets,additional_routers,additional_bgp_speakers,partner_type,created_at -Partner A,partnera@example.com,AS1234,,,"AS100,AS200",,"Router1,Router2",NREN,2024-03-14 -Partner B,partnerb@example.com,AS5678,,,"AS300,AS400",,"Router3,Router4",RE_PEER,2024-03-15 -Partner C,partnerc@example.com,AS91011,,,"AS500,AS600",,"Router5,Router6",PUBLIC_PEER,2024-03-16 - diff --git a/gso/cli/imports.py b/gso/cli/imports.py index 5ef0233c..64a6af56 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -212,7 +212,7 @@ def import_partners_from_csv(file_path: Path) -> list[dict]: @app.command() -def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV file containing partners")): +def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV file containing partners")) -> None: """Import partners from a CSV file into the database.""" typer.echo(f"Importing partners from {file_path} ...") @@ -221,9 +221,7 @@ def import_partners(file_path: str = typer.Argument(..., help="Path to the CSV f try: for partner in partners: if partner.get("created_at"): - partner["created_at"] = datetime.strptime(partner["created_at"], "%Y-%m-%d").replace( - tzinfo=UTC - ) + partner["created_at"] = datetime.strptime(partner["created_at"], "%Y-%m-%d").replace(tzinfo=UTC) new_partner = PartnerTable(**partner) db.session.add(new_partner) diff --git a/gso/services/partners.py b/gso/services/partners.py index 01bb97cf..f2080380 100644 --- a/gso/services/partners.py +++ b/gso/services/partners.py @@ -49,8 +49,6 @@ def create_partner( raise finally: db.session.close() - finally: - db.session.close() def delete_partner_by_name(name: str) -> None: @@ -67,5 +65,3 @@ def delete_partner_by_name(name: str) -> None: raise finally: db.session.close() - finally: - db.session.close() diff --git a/test/fixtures.py b/test/fixtures.py index 891a936f..9575cdfb 100644 --- a/test/fixtures.py +++ b/test/fixtures.py @@ -258,7 +258,8 @@ def iptrunk_subscription_factory(iptrunk_side_subscription_factory, faker, geant iptrunk_sides = iptrunk_sides or [iptrunk_side_a, iptrunk_side_b] iptrunk_subscription = IptrunkInactive.from_product_id( - product_id, customer_id=partner["partner_id"], insync=True) + product_id, customer_id=partner["partner_id"], insync=True + ) iptrunk_subscription.iptrunk.geant_s_sid = geant_s_sid iptrunk_subscription.iptrunk.iptrunk_description = iptrunk_description iptrunk_subscription.iptrunk.iptrunk_type = iptrunk_type -- GitLab