Skip to content

Commit

Permalink
Poetry2 (socotecio#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMontagu authored and nohzafk committed Jan 28, 2025
1 parent ba5c6ce commit f22bd9a
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 22 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv/
2 changes: 1 addition & 1 deletion .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install pip dependencies
if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
pip install psycopg2 poetry proto-parser
pip install psycopg2 'poetry<3.0.0' proto-parser
- name: Install poetry
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Install pip dependencies
if: steps.pip-cache.outputs.cache-hit != 'true'
run: |
pip install psycopg2 poetry
pip install psycopg2 'poetry<3.0.0'
- name: Poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
- pip install 'poetry<3.0.0'
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ RUN sed -i 's/^# *\(fr_FR.UTF-8\)/\1/' /etc/locale.gen
RUN sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen
RUN locale-gen

RUN pip install --no-cache-dir psycopg2 'poetry<2.0.0'
RUN pip install --no-cache-dir psycopg2 'poetry<3.0.0'

RUN poetry config virtualenvs.create false

COPY pyproject.toml .
COPY poetry.lock .


FROM builder AS server

RUN poetry install
COPY ./django_socio_grpc /opt/code/django_socio_grpc
RUN poetry install --with dev

FROM builder AS docs

Expand All @@ -31,5 +31,7 @@ RUN apt update \
&& apt clean

COPY docs docs
COPY ./django_socio_grpc /opt/code/django_socio_grpc
RUN poetry config virtualenvs.create false
RUN poetry install --with docs
RUN cd docs && make html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from django_socio_grpc.protobuf.json_format import message_to_dict
from django_socio_grpc.protobuf.tests.protos import test_proto_pb2
from django_socio_grpc.tests.protobuf.protos import test_proto_pb2


def test_message_to_dict_include_optional_not_one_of():
message = test_proto_pb2.MyMessage(string_field="test")

result = message_to_dict(message)
assert len(result) == 2
assert len(result) == 1
assert result["string_field"] == "test"
assert result["optional_string_field"] is None
assert message.HasField("optional_string_field") is False

message = test_proto_pb2.MyMessage(string_field="test", optional_string_field="test")

Expand Down
5 changes: 4 additions & 1 deletion django_socio_grpc/tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def test_resolve_user_with_multiple_authentications(self):
dummy_service = DummyService()
dummy_service.context = FakeContext()
dummy_service.context.META = {"HTTP_AUTHORIZATION": "faketoken"}
dummy_service.authentication_classes = [FakeNotHandlingAuthentication, FakeAuthentication]
dummy_service.authentication_classes = [
FakeNotHandlingAuthentication,
FakeAuthentication,
]

auth_user_tuple = dummy_service.resolve_user()
self.assertEqual(auth_user_tuple, ({"email": "[email protected]"}, "faketoken"))
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- test-database
volumes:
- .:/opt/code
- ./.venv:/opt/code/.venv:delegated
- ./test_utils:/opt/code/test_utils
# ports:
# - "7000:80"
Expand Down
97 changes: 90 additions & 7 deletions poetry.lock

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
[project]
requires-python = ">=3.10"

[tool.poetry]
name = "django-socio-grpc"
version = "0.1.1"
description = "Fork of django-grpc-framework with more feature maintained by the socio team. Make GRPC with django easy."
authors = ["Adrien Montagu <[email protected]>"]
authors = [
{name = "Adrien Montagu ", email = "[email protected]"}
]
license = "Apache-2.0"
requires-python = ">=3.10"

[tool.poetry]
packages = [
{ include = "django_socio_grpc" },
]

[tool.poetry.scripts]
tests = "test_utils.load_tests:launch"
Expand Down Expand Up @@ -43,7 +48,7 @@ myst-parser = "^2.0.0"
sphinx-autodoc2 = "^0.5"

[build-system]
requires = ["poetry-core>=1.0.0,<2.0.0"]
requires = ["poetry-core>=2.0.1,<3.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.ruff.lint.isort]
Expand Down

0 comments on commit f22bd9a

Please sign in to comment.