Skip to content

Commit

Permalink
build: add py3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
uniqueg committed May 20, 2024
1 parent 9c48e6a commit 0ef2bee
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
py-version-img: [
["3.9", "3.9-slim-bookworm"],
["3.10", "3.10-slim-bookworm"],
["3.11", "3.11-slim-bookworm"]
["3.11", "3.11-slim-bookworm"],
["3.12", "3.12-slim-bookworm"],
]
mongodb-version: ["4.4", "5.0", "6.0", "7.0"]
mongodb-port: [12345]
Expand Down Expand Up @@ -83,7 +84,8 @@ jobs:
py-version-img-tag: [
["3.9", "3.9-slim-bookworm", ""],
["3.10", "3.10-slim-bookworm", ""],
["3.11", "3.11-slim-bookworm", "latest"],
["3.11", "3.11-slim-bookworm", ""],
["3.12", "3.12-slim-bookworm", "latest"],
]

steps:
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PY_IMAGE=3.11-slim-bookworm
ARG PY_IMAGE=3.12-slim-bookworm
FROM python:$PY_IMAGE as base

# Metadata
Expand Down
2 changes: 1 addition & 1 deletion examples/petstore-access-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Some notes:
> executing the build command. For example:
>
> ```bash
> export PETSTORE_PY_IMAGE=3.11-slim-bookworm
> export PETSTORE_PY_IMAGE=3.12-slim-bookworm
> ```
>
> * In case Docker complains about port conflicts or if any of the used ports
Expand Down
2 changes: 1 addition & 1 deletion examples/petstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Some notes:
> executing the build command. For example:
>
> ```bash
> export PETSTORE_PY_IMAGE=3.11-slim-bookworm
> export PETSTORE_PY_IMAGE=3.12-slim-bookworm
> ```
>
> * In case Docker complains about port conflicts or if any of the used ports
Expand Down
13 changes: 6 additions & 7 deletions foca/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
from enum import Enum
from functools import reduce
import importlib
from importlib.resources import path as resource_path
import operator
from pathlib import Path
from typing import (Any, Dict, List, Optional, Union)

from pkg_resources import resource_filename

from pydantic import (BaseModel, Field, validator) # pylint: disable=E0611
import pymongo

Expand Down Expand Up @@ -710,11 +709,11 @@ def validate_model_path(cls, v: Optional[Path]): # pylint: disable=E0213
if path is not provided.
"""
if v is None:
return str(
resource_filename(
ACCESS_CONTROL_BASE_PATH, DEFAULT_MODEL_FILE
)
)
with resource_path(
ACCESS_CONTROL_BASE_PATH,
DEFAULT_MODEL_FILE
) as _path:
return str(_path)

model_path = Path(v)
if not model_path.is_absolute():
Expand Down
7 changes: 4 additions & 3 deletions foca/security/access_control/register_access_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from functools import wraps
from pkg_resources import resource_filename
from importlib.resources import path as resource_path
from pathlib import Path
from typing import (Callable, Optional, Tuple)

Expand Down Expand Up @@ -108,9 +108,10 @@ def register_permission_specs(
"""
# Check if default, get package path variables for specs.
if access_control_config.api_specs is None:
spec_path = str(resource_filename(
with resource_path(
ACCESS_CONTROL_BASE_PATH, DEFAULT_API_SPEC_PATH
))
) as _path:
spec_path = str(_path)
else:
spec_path = access_control_config.api_specs

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Internet :: WWW/HTTP",
"Topic :: System :: Systems Administration",
"Topic :: Utilities",
Expand Down
17 changes: 8 additions & 9 deletions tests/security/test_cors.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""Unit test for security.cors.py"""

from foca.security.cors import enable_cors
from flask import Flask
from unittest.mock import patch

from flask import Flask

from unittest.mock import patch
from foca.security.cors import enable_cors


@patch('flask_cors.CORS')
def test_enable_cors(test_patch):
"""Test that CORS is called with app as a parameter
"""
def test_enable_cors():
"""Test that CORS is called with app as a parameter."""
app = Flask(__name__)
assert enable_cors(app) is None
assert test_patch.called_with(app)
with patch('foca.security.cors.CORS') as mock_cors:
enable_cors(app)
mock_cors.assert_called_once_with(app)

0 comments on commit 0ef2bee

Please sign in to comment.