Skip to content

Commit

Permalink
chore: Move tests outside main package
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jun 16, 2024
1 parent 57da19a commit 9117681
Show file tree
Hide file tree
Showing 19 changed files with 23 additions and 20 deletions.
File renamed without changes.
22 changes: 12 additions & 10 deletions paikkala/tests/demo_data.py → paikkala/demo_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ def create_scatter_program(zones: list[Zone], room=None):
row: Row
for row in zone.rows.all():
# Leave one seat per row
_ = list(row.reserve(
program=program,
count=row.capacity - 1,
user=None,
name='Señor Developer',
email='test@localhost',
phone=None,
attempt_sequential=False,
excluded_numbers=None,
))
_ = list(
row.reserve(
program=program,
count=row.capacity - 1,
user=None,
name='Señor Developer',
email='test@localhost',
phone=None,
attempt_sequential=False,
excluded_numbers=None,
)
)

status = zone.get_reservation_status(program)
assert status.total_remaining == zone.rows.count()
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions paikkala/management/commands/paikkala_load_demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
from django.db.transaction import atomic
from django.utils.crypto import get_random_string

from paikkala.excs import NoCapacity
from paikkala.models import Zone
from paikkala.tests.demo_data import (
from paikkala.demo_data import (
SIBELIUSTALO_DEFAULT_ROOM_NAME,
create_jussi_program,
import_sibeliustalo_zones,
)
from paikkala.excs import NoCapacity
from paikkala.models import Zone


class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--yes', '-y', default=False, action='store_true')
parser.add_argument("--yes", "-y", default=False, action="store_true")

@atomic
def handle(self, yes: bool, **options: Any) -> None:
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions paikkala/tests/conftest.py → paikkala_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from django.utils.crypto import get_random_string
from django.utils.timezone import now

from paikkala.models import Program, Room, Row, Zone
from paikkala.tests.demo_data import (
from paikkala.demo_data import (
create_jussi_program,
create_scatter_program,
create_workshop_program,
Expand All @@ -15,6 +14,7 @@
create_workshop_zone,
import_sibeliustalo_zones,
)
from paikkala.models import Program, Room, Row, Zone


@pytest.fixture
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,4 @@ def test_automatic_max_tickets(jussi_program):
def test_attempt_sequential(lattia_program, attempt_sequential):
zone = lattia_program.zones[0]
tickets = list(lattia_program.reserve(zone=zone, count=3, attempt_sequential=attempt_sequential))
assert [t.number for t in tickets] == (
[1, 2, 6] if not attempt_sequential else [6, 7, 8]
)
assert [t.number for t in tickets] == ([1, 2, 6] if not attempt_sequential else [6, 7, 8])
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ max-complexity = 10
"ANN003",
"ANN201",
]
"*/tests/*.py" = [
"paikkala_tests/*.py" = [
"ANN",
]
"*/migrations/*.py" = [
"ANN",
"E501",
]

[tool.ruff.format]
quote-style = "preserve"

0 comments on commit 9117681

Please sign in to comment.