diff --git a/example.csv b/example.csv deleted file mode 100644 index 8b7a5d92dde262a65d9994f113d162d9a37e91ea..0000000000000000000000000000000000000000 --- 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 5ef0233c05361b4d4d97bc212789bd99d8ade120..64a6af56cdb691a15c796fc27fce8e0d297b7950 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 01bb97cf559a609170c36799291cebe0be3b3dbb..f2080380e30773156af456daa080ae1e37f0a7bc 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 891a936f8faad9f06f3b227cfa48806bcbb87842..9575cdfbbf4c88fec5f67e10e1707113ae971b8a 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