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 aa89897
Show file tree
Hide file tree
Showing 18 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions paikkala/management/commands/paikkala_load_demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from paikkala.excs import NoCapacity
from paikkala.models import Zone
from paikkala.tests.demo_data import (
from paikkala_tests.demo_data import (
SIBELIUSTALO_DEFAULT_ROOM_NAME,
create_jussi_program,
import_sibeliustalo_zones,
Expand All @@ -18,25 +18,25 @@

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:
if not yes:
self.stderr.write('this command requires the --yes parameter, as it will mess up your database')
self.stderr.write("this command requires the --yes parameter, as it will mess up your database")

Check warning on line 26 in paikkala/management/commands/paikkala_load_demo_data.py

View check run for this annotation

Codecov / codecov/patch

paikkala/management/commands/paikkala_load_demo_data.py#L26

Added line #L26 was not covered by tests
return
sibeliustalo_zones = list(Zone.objects.filter(room__name=SIBELIUSTALO_DEFAULT_ROOM_NAME))
if not sibeliustalo_zones:
sibeliustalo_zones = import_sibeliustalo_zones()
room = sibeliustalo_zones[0].room
program = room.program_set.first() or create_jussi_program(sibeliustalo_zones, room=room)
user = User.objects.create_user(f'random-demo-{get_random_string(12)}')
user = User.objects.create_user(f"random-demo-{get_random_string(12)}")
prog_zones = list(program.zones)
for _ in range(10):
zone = random.choice(prog_zones)
count = random.randint(1, 5)
try:
tickets = list(program.reserve(zone=zone, count=count, user=user))
self.stdout.write(f'{user}: Reserved {len(tickets):d} tickets in {zone.name}')
self.stdout.write(f"{user}: Reserved {len(tickets):d} tickets in {zone.name}")
except NoCapacity:
break
File renamed without changes.
10 changes: 5 additions & 5 deletions paikkala/tests/conftest.py → paikkala_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.utils.timezone import now

from paikkala.models import Program, Room, Row, Zone
from paikkala.tests.demo_data import (
from paikkala_tests.demo_data import (
create_jussi_program,
create_scatter_program,
create_workshop_program,
Expand Down Expand Up @@ -54,14 +54,14 @@ def workshop_program(workshop_room, workshop_row):

@pytest.fixture
def lattia_program():
room = Room.objects.create(name='huone')
zone = Zone.objects.create(name='lattia', room=room)
row = Row.objects.create(zone=zone, start_number=1, end_number=10, excluded_numbers='3,4,5')
room = Room.objects.create(name="huone")
zone = Zone.objects.create(name="lattia", room=room)
row = Row.objects.create(zone=zone, start_number=1, end_number=10, excluded_numbers="3,4,5")
assert row.capacity == 7
t = now()
program = Program.objects.create(
room=zone.room,
name='program',
name="program",
max_tickets=100,
reservation_start=t,
reservation_end=t + timedelta(days=1),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit aa89897

Please sign in to comment.