Skip to content

Commit

Permalink
lint, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
eastandwestwind committed Dec 18, 2024
1 parent 2acba65 commit 2ea6f36
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
"""

from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "10c6b7709be3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

import sqlalchemy as sa
from alembic import op

from sqlalchemy import text
from sqlalchemy.engine import Connection


# revision identifiers, used by Alembic.
revision = "ae65da77c468"
down_revision = "10c6b7709be3"
Expand Down
16 changes: 12 additions & 4 deletions src/fides/api/api/v1/endpoints/generic_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sqlalchemy.orm import Session
from sqlalchemy.sql.expression import select
from starlette import status
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY, HTTP_404_NOT_FOUND
from starlette.status import HTTP_404_NOT_FOUND, HTTP_422_UNPROCESSABLE_ENTITY

from fides.api.api.deps import get_db
from fides.api.common_exceptions import KeyOrNameAlreadyExists
Expand All @@ -28,15 +28,15 @@
DataUse,
DataUseCreateOrUpdate,
)
from fides.api.util.errors import ForbiddenIsDefaultTaxonomyError
from fides.api.util.errors import FidesError, ForbiddenIsDefaultTaxonomyError
from fides.api.util.filter_utils import apply_filters_to_query
from fides.common.api.scope_registry import (
DATA_CATEGORY_CREATE,
DATA_CATEGORY_UPDATE,
DATA_SUBJECT_CREATE,
DATA_USE_CREATE,
DATASET_READ,
DATA_USE_UPDATE,
DATA_CATEGORY_UPDATE,
DATASET_READ,
)
from fides.common.api.v1.urn_registry import V1_URL_PREFIX

Expand Down Expand Up @@ -162,6 +162,10 @@ def validate_and_create_taxonomy(
"""
Validate and create a taxonomy element.
"""
if not data.fides_key:
raise FidesError(
f"Fides key is required to create a {model.__name__} resource"
)
if isinstance(model, ModelWithDefaultField) and data.is_default:
raise ForbiddenIsDefaultTaxonomyError(
model.__name__, data.fides_key, action="create"
Expand All @@ -181,6 +185,10 @@ def validate_and_update_taxonomy(
"""
Validate and update a taxonomy element.
"""
if not data.fides_key:
raise FidesError(
f"Fides key is required to update {resource.__name__}"
)
if isinstance(resource, ModelWithDefaultField) and data.is_default:
raise ForbiddenIsDefaultTaxonomyError(
resource.__name__, data.fides_key, action="update"
Expand Down
2 changes: 1 addition & 1 deletion src/fides/api/models/sql_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from sqlalchemy.exc import IntegrityError
from sqlalchemy.ext.asyncio import AsyncSession, async_object_session
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import Session, relationship
from sqlalchemy.orm import RelationshipProperty, Session, relationship
from sqlalchemy.sql import Select
from sqlalchemy.sql.elements import Case
from sqlalchemy.sql.sqltypes import DateTime
Expand Down
1 change: 1 addition & 0 deletions tests/ctl/core/test_taxonomy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Session

from fides.api.models.sql_models import DataUse


Expand Down
2 changes: 1 addition & 1 deletion tests/ops/api/v1/endpoints/test_taxonomy_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from fides.common.api.scope_registry import (
DATA_USE,
DATA_USE_CREATE,
STORAGE_READ,
DATA_USE_UPDATE,
STORAGE_READ,
)
from fides.common.api.v1.urn_registry import V1_URL_PREFIX

Expand Down

0 comments on commit 2ea6f36

Please sign in to comment.