Skip to content

Commit

Permalink
PPS-1617 Dependency update (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre authored Nov 5, 2024
1 parent eff41c4 commit 3f22277
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 112 deletions.
16 changes: 11 additions & 5 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ components:
\ using in place of whatever GUID\n specified"
properties:
aliases:
items: {}
items:
type: string
title: Aliases
type: array
title: AliasObjInput
Expand Down Expand Up @@ -68,7 +69,9 @@ components:
properties:
loc:
items:
type: string
anyOf:
- type: string
- type: integer
title: Location
type: array
msg:
Expand All @@ -93,7 +96,7 @@ components:
info:
title: Framework Services Object Management Service
version: 4.0.2
openapi: 3.0.2
openapi: 3.1.0
paths:
/_status:
get:
Expand Down Expand Up @@ -283,10 +286,12 @@ paths:
\ }\n },\n ...\n ]"
operationId: get_aggregate_metadata_for_commons_aggregate_metadata__name__get
parameters:
- in: path
- description: Return the results without grouping items by commons.
in: path
name: name
required: true
schema:
description: Return the results without grouping items by commons.
title: Name
type: string
responses:
Expand Down Expand Up @@ -434,7 +439,8 @@ paths:
content:
application/json:
schema:
items: {}
items:
type: object
title: Data List
type: array
required: true
Expand Down
254 changes: 172 additions & 82 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "Apache-2.0"

[tool.poetry.dependencies]
python = "^3.9"
fastapi = "^0.65.2"
fastapi = "*"
uvicorn = {extras = ["standard"], version="^0.18.2"}
gunicorn = ">=20.0.4"
gino = {version = "^1.0.0", extras = ["starlette"]}
Expand All @@ -31,6 +31,7 @@ bleach = ">=3.3.1"
tenacity = ">=8.0.0"
pydash = "^5.1.0"
pathvalidate = "^3.2.0"
python-multipart = "<1"

[tool.poetry.dev-dependencies]
pytest = "^5.3"
Expand Down
8 changes: 4 additions & 4 deletions src/mds/agg_mds/query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fastapi import HTTPException, Query, APIRouter, Request
from fastapi import HTTPException, Path, Query, APIRouter, Request
from starlette.status import HTTP_404_NOT_FOUND
from mds import config
from mds.agg_mds import datastore
Expand Down Expand Up @@ -143,9 +143,9 @@ async def get_aggregate_metadata(

@mod.get("/aggregate/metadata/{name}")
async def get_aggregate_metadata_for_commons(
name: str = Query(
False, description="Return the results without grouping items by commons."
)
name: str = Path(
description="Return the results without grouping items by commons."
),
):
"""et all metadata records from a commons by name
Expand Down
15 changes: 4 additions & 11 deletions src/mds/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,23 @@
to point to the same blob, aliases allow that without duplicating the
actual blob.
"""
import json
import re
from typing import Union

from asyncpg import UniqueViolationError, ForeignKeyViolationError
from fastapi import HTTPException, APIRouter, Depends
from pydantic import BaseModel
from sqlalchemy import bindparam
from sqlalchemy.dialects.postgresql import insert
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.status import (
HTTP_200_OK,
HTTP_201_CREATED,
HTTP_204_NO_CONTENT,
HTTP_400_BAD_REQUEST,
HTTP_404_NOT_FOUND,
HTTP_409_CONFLICT,
)
import urllib.parse

from .admin_login import admin_required
from .models import db, MetadataAlias, Metadata
from . import config, logger
from .objects import FORBIDDEN_IDS
from .models import MetadataAlias
from . import logger

mod = APIRouter()

Expand All @@ -43,7 +36,7 @@ class AliasObjInput(BaseModel):
specified
"""

aliases: list = None
aliases: list[str] = None


@mod.post("/metadata/{guid:path}/aliases")
Expand Down
3 changes: 1 addition & 2 deletions src/mds/maintain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import re

from asyncpg import UniqueViolationError
from fastapi import HTTPException, APIRouter, Depends
Expand All @@ -24,7 +23,7 @@

@mod.post("/metadata")
async def batch_create_metadata(
request: Request, data_list: list, overwrite: bool = True
request: Request, data_list: list[dict], overwrite: bool = True
):
"""Create metadata in batch."""
request.scope.get("add_close_watcher", lambda: None)()
Expand Down
20 changes: 13 additions & 7 deletions tests/test_aliases.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import gino
import httpx
import pytest
import urllib.parse

Expand Down Expand Up @@ -28,14 +28,20 @@ def test_create_read_delete_new_aliases(guid, aliases, client, is_post):
client.post(f"/metadata/{guid}", json=data).raise_for_status()

if is_post:
client.post(
f"/metadata/{guid}/aliases", json={"aliases": aliases}
).raise_for_status()
res = client.post(f"/metadata/{guid}/aliases", json={"aliases": aliases})
if aliases is None: # the endpoint expects a list
with pytest.raises(httpx.HTTPStatusError, match="422 Unprocessable Entity"):
res.raise_for_status()
else:
res.raise_for_status()
else:
# use PUT instead of POST, should result in same behavior for new aliases
client.put(
f"/metadata/{guid}/aliases", json={"aliases": aliases}
).raise_for_status()
res = client.put(f"/metadata/{guid}/aliases", json={"aliases": aliases})
if aliases is None: # the endpoint expects a list
with pytest.raises(httpx.HTTPStatusError, match="422 Unprocessable Entity"):
res.raise_for_status()
else:
res.raise_for_status()

# convert None to empty list for comparison of output
# because we always expect the output to be a list, even if the input is not
Expand Down

0 comments on commit 3f22277

Please sign in to comment.