Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: pnpm run build
- name: Run tests
run: |
coverage run --branch -m pytest froide/
pytest -n auto --cov --cov-report= froide/
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
env:
DATABASE_URL: postgis://postgres:postgres@localhost/froide
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local_*.py
data/
files/
froide/tests/testdata/*/
.coverage
.coverage*
*/_build/
.idea
htmlcov/
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ export PYTHONWARNINGS=default

test:
ruff check
coverage run --branch -m pytest froide/
coverage report

testui:
coverage run --branch -m pytest --browser chromium froide/tests/live/
pytest --cov froide/

.PHONY: htmlcov
htmlcov:
Expand Down
1 change: 1 addition & 0 deletions froide/campaign/tests/test_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_campaign_request_match(world, client):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_campaign_request_match_live(
page: Page, live_server, public_body_with_index, dummy_user
Expand Down
1 change: 1 addition & 0 deletions froide/foirequest/tests/test_api_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def test_search(self):
response = self.client.get("/api/v1/request/search/?q=Number")
self.assertEqual(response.status_code, 200)

@pytest.mark.xdist_group(name="sequential")
def test_search_similar(self):
factories.delete_index()
search_url = "/api/v1/request/search/"
Expand Down
1 change: 1 addition & 0 deletions froide/foirequest/tests/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@ def test_resolution(world, client):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
def test_search(world, client, pb):
pb = PublicBody.objects.all()[0]
factories.rebuild_index()
Expand Down
8 changes: 8 additions & 0 deletions froide/foirequest/tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_request_prefilled_redirect(world, client):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
def test_list_requests(world, client):
factories.rebuild_index()
response = client.get(reverse("foirequest-list"))
Expand All @@ -118,6 +119,7 @@ def test_list_requests(world, client):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
def test_list_jurisdiction_requests(world, client):
factories.rebuild_index()
juris = Jurisdiction.objects.all()[0]
Expand Down Expand Up @@ -151,6 +153,7 @@ def test_list_jurisdiction_requests(world, client):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
def test_tagged_requests(world, client):
tag_slug = "awesome"
req = FoiRequest.published.all()[0]
Expand All @@ -170,6 +173,7 @@ def test_tagged_requests(world, client):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
def test_publicbody_requests(world, client):
factories.rebuild_index()
req = FoiRequest.published.all()[0]
Expand All @@ -188,6 +192,7 @@ def test_publicbody_requests(world, client):


@pytest.mark.django_db(transaction=True)
@pytest.mark.xdist_group(name="sequential")
def test_list_no_identical(world, client):
factories.FoiRequestFactory.create(site=world)
factories.rebuild_index()
Expand Down Expand Up @@ -277,6 +282,7 @@ def test_auth_links(world, client):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
def test_feed(world, client):
factories.rebuild_index()

Expand Down Expand Up @@ -673,6 +679,7 @@ def jurisdiction_with_many_requests_slug(request: pytest.FixtureRequest):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.parametrize(
"filter_field,filter_value,filter_value_function",
[["jurisdiction", None, jurisdiction_with_many_requests_slug], ["q", "*", None]],
Expand Down Expand Up @@ -727,6 +734,7 @@ def dict_combinations_all_r(sequence):


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
def test_request_list_path_filter(
client: Client,
jurisdiction_with_many_requests: Jurisdiction,
Expand Down
1 change: 1 addition & 0 deletions froide/helper/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, pk):
self.query_highlight = None


@pytest.mark.xdist_group(name="sequential")
class TestBaseSearchFilterSetQueryPreprocessing:
def test_auto_query_without_query_value(self):
qs = DummyQS()
Expand Down
2 changes: 2 additions & 0 deletions froide/publicbody/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def publicbody_data(db):
}


@pytest.mark.xdist_group(name="sequential")
class TestPublicBodyView:
"""Tests for the publicbody list view and its search/filter functionality."""

Expand Down Expand Up @@ -160,6 +161,7 @@ def test_search_filters(
assert result_names == set(expected_names)


@pytest.mark.xdist_group(name="sequential")
class TestPublicBodySearchAPI:
"""Tests for the publicbody search API.

Expand Down
3 changes: 3 additions & 0 deletions froide/publicbody/tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from django.test import TestCase
from django.urls import reverse

import pytest

from froide.account.factories import UserFactory
from froide.foirequest.tests.factories import make_world, rebuild_index
from froide.georegion.models import GeoRegion
Expand All @@ -29,6 +31,7 @@ class PublicBodyTest(TestCase):
def setUp(self):
self.site = make_world()

@pytest.mark.xdist_group(name="sequential")
def test_web_page(self):
pb = PublicBody.objects.all()[0]
category = CategoryFactory.create(is_topic=True)
Expand Down
1 change: 1 addition & 0 deletions froide/tests/live/test_redaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def get_colors_from_image(image: Image) -> set:


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
@override_settings(SERVE_MEDIA=True)
async def test_redaction(world, live_server, settings, page: Page):
Expand Down
8 changes: 8 additions & 0 deletions froide/tests/live/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_make_not_logged_in_request(
page: Page, live_server, public_body_with_index
Expand Down Expand Up @@ -79,6 +80,7 @@ async def test_make_not_logged_in_request(


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_make_not_logged_in_request_to_public_body(
page: Page, live_server, world
Expand Down Expand Up @@ -124,6 +126,7 @@ async def test_make_not_logged_in_request_to_public_body(


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_make_logged_in_request(
page, live_server, public_body_with_index, dummy_user
Expand Down Expand Up @@ -160,6 +163,7 @@ async def test_make_logged_in_request(


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_make_logged_in_request_too_many(
page: Page,
Expand Down Expand Up @@ -195,6 +199,7 @@ async def test_make_logged_in_request_too_many(


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_make_request_logged_out_with_existing_account(
page: Page, live_server, world
Expand Down Expand Up @@ -238,6 +243,7 @@ async def test_make_request_logged_out_with_existing_account(


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_edit_request_boilerplate(
page: Page, live_server, public_body_with_index, dummy_user
Expand Down Expand Up @@ -283,6 +289,7 @@ async def test_edit_request_boilerplate(


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
async def test_skip_search_similar(
page: Page, live_server, world, public_body_with_index
Expand Down Expand Up @@ -322,6 +329,7 @@ async def test_skip_search_similar(


@pytest.mark.django_db
@pytest.mark.xdist_group(name="sequential")
@pytest.mark.asyncio(loop_scope="session")
@pytest.mark.parametrize(
"from_resolution, to_resolution",
Expand Down
11 changes: 4 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ dependencies = [
[dependency-groups]
dev = [
"beautifulsoup4",
"coverage[toml]",
"django-coverage-plugin",
"django-extended-makemessages>=1.7.1",
"django-stubs",
Expand All @@ -92,6 +91,8 @@ dev = [
"types-python-dateutil",
"types-requests",
"prek>=0.3.5",
"pytest-xdist>=3.8.0",
"pytest-cov>=7.1.0",
]

[build-system]
Expand Down Expand Up @@ -146,16 +147,12 @@ show_missing = true
skip_covered = true
exclude_lines = ["pragma: no cover"]

[tool.pytest.ini_options]
[tool.pytest]
DJANGO_CONFIGURATION = "Test"
DJANGO_SETTINGS_MODULE = "froide.settings"
python_files = ["tests.py", "test_*.py", "*_tests.py"]
addopts = ["--reuse-db"]
addopts = ["--reuse-db", "--dist", "loadgroup"]
markers = ["no_delivery_mock"]
filterwarnings = [
"ignore::DeprecationWarning:(?!froide).*",
"ignore::PendingDeprecationWarning:(?!froide)*",
]

[tool.mypy]
plugins = ["mypy_django_plugin.main"]
Expand Down
42 changes: 40 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading