Skip to content

Commit

Permalink
Issue #218: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Werbrouck committed Nov 29, 2024
1 parent fb840d1 commit d43a7b2
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 46 deletions.
32 changes: 0 additions & 32 deletions fertiscan/db/queries/organization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,38 +217,6 @@ def get_organization_json(cursor: Cursor, fertilizer_id: UUID) -> dict:
else:
return {}


@handle_query_errors(OrganizationUpdateError)
def upsert_organization(cursor: Cursor, information_id):
"""
This function update a organization in the database.
Parameters:
- cursor (cursor): The cursor of the database.
- organization_id (str): The UUID of the organization.
- name (str): The name of the organization.
- website (str): The website of the organization.
- phone_number (str): The phone number of the organization.
- location_id (str): The UUID of the location.
Returns:
- str: The UUID of the organization
"""
query = """
SELECT upsert_organization(%s)
"""
cursor.execute(
query,
(
information_id,
),
)
if result := cursor.fetchone():
return result[0]
raise OrganizationUpdateError("Failed to update Organization. No data returned.")



@handle_query_errors(OrganizationInformationUpdateError)
def update_organization_info(
cursor: Cursor, information_id:UUID, name, website, phone_number
Expand Down
2 changes: 1 addition & 1 deletion tests/fertiscan/db/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def test_delete_label_with_linked_organization_information(self):
organization_id = organization.new_organization_information(
self.cursor,self.address, self.name, self.website, self.phone, self.label_information_id,False,True
)
label_info = label.get_label_information_json(self.cursor, self.label_information_id)
# label_info = label.get_label_information_json(self.cursor, self.label_information_id)
# Attempt to delete the inspection, which should raise a notice but not fail
deleted_rows = label.delete_label_info(self.cursor, self.label_information_id)
self.assertGreaterEqual(deleted_rows,1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import psycopg
from dotenv import load_dotenv

from fertiscan.db.queries import organization

load_dotenv()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import unittest

import psycopg
from dotenv import load_dotenv

import datastore.db.__init__ as db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import unittest

import psycopg
from dotenv import load_dotenv

import datastore.db.__init__ as db
Expand Down
10 changes: 6 additions & 4 deletions tests/fertiscan/db/update_inspection/test_update_inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
import os
import unittest

import psycopg
from dotenv import load_dotenv

import datastore.db.__init__ as db
from datastore.db.metadata import picture_set, validator
from datastore.db.metadata import picture_set
from datastore.db.queries import user,picture
from fertiscan.db.queries import label, inspection
from fertiscan.db.queries import label
from fertiscan.db.metadata.inspection import (
DBInspection,
Inspection,
OrganizationInformation,
)
from fertiscan.db.queries.inspection import get_inspection_dict, update_inspection
from fertiscan.db.queries import organization
Expand Down Expand Up @@ -116,6 +114,7 @@ def test_update_inspection_with_verified_false(self):
self.inspector_id,
altered_inspection.model_dump(),
)
Inspection.model_validate(**update_inspection_result)

# Verify the inspection record was updated in the database
updated_inspection = get_inspection_dict(self.cursor, self.inspection_id)
Expand Down Expand Up @@ -269,6 +268,9 @@ def test_update_inspection_with_verified_true(self):
(altered_inspection.organizations[0].name,),
)
organization_id = self.cursor.fetchone()[0]
self.assertIsNotNone(
organization_id, "An organization record should have been created."
)


def test_update_inspection_unauthorized_user(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import unittest

from dotenv import load_dotenv
from psycopg import connect

from fertiscan import get_full_inspection_json
from fertiscan.db.metadata.inspection import Inspection
Expand Down
3 changes: 1 addition & 2 deletions tests/fertiscan/db/update_inspection/test_update_metrics.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import os
import unittest

import psycopg
from dotenv import load_dotenv

import datastore.db.__init__ as db
import fertiscan.db.queries.label as label
from fertiscan.db.metadata.inspection import Metric, Metrics, OrganizationInformation
from fertiscan.db.metadata.inspection import Metric, Metrics

load_dotenv()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import os
import unittest

import psycopg
from dotenv import load_dotenv

import datastore.db.__init__ as db
import fertiscan.db.queries.sub_label as sub_label
import fertiscan.db.queries.label as label
from fertiscan.db.metadata.inspection import (
Inspection,
OrganizationInformation,
SubLabel,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import unittest

import psycopg
from dotenv import load_dotenv

import datastore.db.__init__ as db
Expand Down

0 comments on commit d43a7b2

Please sign in to comment.