Skip to content

Commit

Permalink
Updated libs & Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanchoyzer committed Sep 22, 2024
1 parent 082780b commit 8d948b0
Show file tree
Hide file tree
Showing 7 changed files with 675 additions and 609 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
cache: 'poetry'

- name: Install Dependencies
run: |
poetry env use 3.11
poetry env use 3.12
poetry install
- name: Run Black
Expand Down Expand Up @@ -72,12 +72,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
cache: 'poetry'

- name: Install Dependencies
run: |
poetry env use 3.11
poetry env use 3.12
poetry install
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.7-slim as base
FROM python:3.12.6-slim as base

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / push-docker-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
RUN python -m pip install --upgrade --no-cache-dir pip wheel setuptools \
&& python -m pip install poetry \
&& poetry config virtualenvs.create false \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![GitHub commit activity](https://img.shields.io/github/commit-activity/y/Sanchoyzer/caraconnect)
![GitHub last commit](https://img.shields.io/github/last-commit/Sanchoyzer/caraconnect)

[![Python](https://img.shields.io/badge/Python-3.11-3776AB.svg?style=flat&logo=python&logoColor=ffdd54)](https://www.python.org)
[![Python](https://img.shields.io/badge/Python-3.12-3776AB.svg?style=flat&logo=python&logoColor=ffdd54)](https://www.python.org)
[![GitHub Actions](https://img.shields.io/badge/github%20actions-%232671E5.svg?logo=githubactions&logoColor=white)](https://github.com/Sanchoyzer/caraconnect/actions)
[![Sentry](https://img.shields.io/static/v1?message=Sentry&color=362D59&logo=Sentry&logoColor=FFFFFF&label=)](https://sentry.io)

Expand Down
1,229 changes: 648 additions & 581 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ skip-string-normalization = true


[tool.mypy]
python_version = '3.11'
python_version = '3.12'
show_error_context = true
check_untyped_defs = true
exclude = ['^.git/', '^venv/', '^.mypy_cache/', '^.pytest_cache/', '^.ruff_cache/', '^.github/',]
Expand All @@ -63,11 +63,10 @@ exclude_dirs = ['tests',]


[tool.pytest.ini_options]
minversion = '6.0'
minversion = '8.2'
addopts = '-s -n auto --dup-fixtures'
testpaths = [
'tests',
]
asyncio_default_fixture_loop_scope = 'function'
testpaths = ['tests']


[tool.poetry]
Expand All @@ -79,26 +78,26 @@ readme = 'README.md'
repository = 'https://github.com/Sanchoyzer/caraconnect'

[tool.poetry.dependencies]
python = '^3.11'
python = '^3.12'
fastapi = {extras = ['all'], version = '^0'}
uvicorn = {extras = ['standard'], version = '^0.30.0'}
gunicorn = '^22.0.0'
gunicorn = '^23.0.0'
sentry-sdk = '^2.10.0'
httpx = '^0.27.0'

[tool.poetry.group.dev.dependencies]
mypy = '^1.8.0'
ruff = '^0.5.0'
black = '^24.4.2'
ruff = '^0.6.0'
black = '^24.8.0'
bandit = '^1.7.5'

[tool.poetry.group.test.dependencies]
faker = '^26.0.0'
faker = '^29.0.0'
pytest = '^8.3.1'
pytest-sugar = '^1.0.0'
pytest-xdist = '^3.3.1'
pytest-cov = '^5.0.0'
pytest-asyncio = '^0.23.8'
pytest-asyncio = '^0.24.0'
pytest-randomly = '^3.15.0'
pytest-deadfixtures = '^2.2.1'

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def path_():
return '/health'


@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_health(client, path_):
r = await client.get(path_)
assert r.status_code == status.HTTP_200_OK, r.text
Expand Down
20 changes: 10 additions & 10 deletions tests/e2e/test_rand_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def create_params(f_create_params):


class TestSetParams:
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_ok(self, client, path_create, values, probabilities):
payload = {'values': values, 'probabilities': probabilities}
r = await client.post(path_create, json=payload)
Expand All @@ -65,7 +65,7 @@ async def test_ok(self, client, path_create, values, probabilities):
assert r_json['values'] == payload['values']
assert r_json['probabilities'] == payload['probabilities']

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_creation_incorrect_len(self, client, path_create, values, probabilities):
values_short = values[1:]
payload = {'values': values_short, 'probabilities': probabilities}
Expand All @@ -80,7 +80,7 @@ async def test_creation_incorrect_len(self, client, path_create, values, probabi
assert r.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, r.text
assert 'Different lens' in r.json()['detail'][0]['msg']

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_creation_zero_len(self, client, path_create):
payload: dict[str, list] = {'values': [], 'probabilities': []}
r = await client.post(path_create, json=payload)
Expand All @@ -90,15 +90,15 @@ async def test_creation_zero_len(self, client, path_create):
for i in range(len(payload)):
assert r_json['detail'][i]['msg'] == error_msg, r_json

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_creation_non_uniq_values(self, client, path_create, values, probabilities):
values[1] = values[0]
payload = {'values': values, 'probabilities': probabilities}
r = await client.post(path_create, json=payload)
assert r.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, r.text
assert 'Non uniq values' in r.json()['detail'][0]['msg']

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_creation_incorrect_probs(self, client, path_create, values, probabilities):
probabilities[0] = -probabilities[0]
payload = {'values': values, 'probabilities': probabilities}
Expand All @@ -112,7 +112,7 @@ async def test_creation_incorrect_probs(self, client, path_create, values, proba
assert r.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY, r.text
assert 'Incorrect values of probabilities' in r.json()['detail'][0]['msg']

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_creation_incorrect_sum_of_probs(
self,
client,
Expand All @@ -128,29 +128,29 @@ async def test_creation_incorrect_sum_of_probs(


class TestGetValues:
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_ok(self, client, path_get, values):
r = await client.get(path_get)
assert r.status_code == status.HTTP_200_OK, r.text
assert (r_json := r.json()) and len(r_json['values']) == 1, r.text
assert r_json['values'][0] in values

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_ok_several_input_data(self, client, path_get_template, faker, f_create_params):
for uid in [await f_create_params() for _ in range(faker.pyint(min_value=2, max_value=9))]:
r = await client.get(path_get_template.format(uid=uid))
assert r.status_code == status.HTTP_200_OK, r.text
assert (r_json := r.json()) and len(r_json['values']) == 1, r.text

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_ok_several_values(self, client, path_get, faker, values):
amount = faker.pyint(min_value=2, max_value=9)
r = await client.get(path_get, params={'amount': amount})
assert r.status_code == status.HTTP_200_OK, r.text
assert (r_json := r.json()) and len(r_json['values']) == amount, r.text
assert all(v in values for v in r_json['values'])

@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_non_existing_uid(self, client, path_get_fake):
r = await client.get(path_get_fake)
assert r.status_code == status.HTTP_404_NOT_FOUND, r.text
Expand Down

0 comments on commit 8d948b0

Please sign in to comment.