-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ogc-1998-landsgemeinde-file-upload
- Loading branch information
Showing
6 changed files
with
122 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import datetime | ||
|
||
from freezegun import freeze_time | ||
from sedate import utcnow | ||
|
||
from onegov.fsi.models.course_attendee import CourseAttendee | ||
|
@@ -44,57 +46,67 @@ def test_attendee( | |
|
||
|
||
def test_course_event(scenario): | ||
|
||
scenario.add_attendee() | ||
scenario.add_course(name='Course') | ||
scenario.add_course_event(scenario.latest_course, max_attendees=20) | ||
delta = datetime.timedelta(days=366) | ||
|
||
# Add a participant via a subscription | ||
event = scenario.latest_event | ||
scenario.add_subscription(event, None, dummy_desc='Placeholder') | ||
scenario.add_subscription(event, scenario.latest_attendee) | ||
|
||
# Add inactive attendee | ||
scenario.add_attendee(active=False) | ||
scenario.add_subscription(event, scenario.latest_attendee) | ||
|
||
scenario.commit() | ||
scenario.refresh() | ||
|
||
event = scenario.latest_event | ||
assert event.subscriptions.count() == 3 | ||
assert event.attendees.count() == 2 | ||
assert event.available_seats == 20 - 3 | ||
assert event.possible_subscribers().first() is None | ||
|
||
# Test possible and excluded subscribers | ||
scenario.add_attendee(username='[email protected]') | ||
attendee_2 = scenario.latest_attendee | ||
|
||
# event = scenario.latest_event | ||
assert event.course | ||
assert event.possible_subscribers(year=event.end.year).all() == [ | ||
attendee_2 | ||
] | ||
|
||
scenario.add_course_event( | ||
scenario.latest_course, | ||
start=event.start + delta, end=event.end + delta, | ||
max_attendees=20 | ||
) | ||
event2 = scenario.latest_event | ||
|
||
# Event for a year later, exclude the one who has a subscription to this | ||
# course | ||
assert event.possible_subscribers(year=event.end.year + 1).count() == 1 | ||
assert event2.possible_subscribers(year=event.end.year).count() == 1 | ||
assert event2.possible_subscribers(year=event.end.year + 1).count() == 2 | ||
assert event.possible_subscribers(external_only=True).count() == 0 | ||
assert event.excluded_subscribers().count() == 2 | ||
assert event2.possible_subscribers().first() == attendee_2 | ||
|
||
assert scenario.latest_course.future_events.count() == 2 | ||
# if current date is last or second last day of the year, then freeze to | ||
# 28th of december | ||
if utcnow().date().month == 12 and utcnow().date().day in (30, 31): | ||
freeze_date = '2024-12-28' | ||
else: | ||
freeze_date = utcnow().date() | ||
|
||
with freeze_time(freeze_date): | ||
scenario.add_attendee() | ||
scenario.add_course(name='Course') | ||
scenario.add_course_event(scenario.latest_course, max_attendees=20) | ||
delta = datetime.timedelta(days=366) | ||
|
||
# Add a participant via a subscription | ||
event = scenario.latest_event | ||
scenario.add_subscription(event, None, dummy_desc='Placeholder') | ||
scenario.add_subscription(event, scenario.latest_attendee) | ||
|
||
# Add inactive attendee | ||
scenario.add_attendee(active=False) | ||
scenario.add_subscription(event, scenario.latest_attendee) | ||
|
||
scenario.commit() | ||
scenario.refresh() | ||
|
||
event = scenario.latest_event | ||
assert event.subscriptions.count() == 3 | ||
assert event.attendees.count() == 2 | ||
assert event.available_seats == 20 - 3 | ||
assert event.possible_subscribers().first() is None | ||
|
||
# Test possible and excluded subscribers | ||
scenario.add_attendee(username='[email protected]') | ||
attendee_2 = scenario.latest_attendee | ||
|
||
# event = scenario.latest_event | ||
assert event.course | ||
assert event.possible_subscribers(year=event.end.year).all() == [ | ||
attendee_2 | ||
] | ||
|
||
scenario.add_course_event( | ||
scenario.latest_course, | ||
start=event.start + delta, end=event.end + delta, | ||
max_attendees=20 | ||
) | ||
event2 = scenario.latest_event | ||
|
||
# Event for a year later, exclude the one who has a subscription to | ||
# this course | ||
assert event.possible_subscribers( | ||
year=event.end.year + 1).count() == 1 | ||
assert event2.possible_subscribers( | ||
year=event.end.year).count() == 1 | ||
assert event2.possible_subscribers( | ||
year=event.end.year + 1).count() == 2 | ||
assert event.possible_subscribers(external_only=True).count() == 0 | ||
assert event.excluded_subscribers().count() == 2 | ||
assert event2.possible_subscribers().first() == attendee_2 | ||
|
||
assert scenario.latest_course.future_events.count() == 2 | ||
|
||
|
||
def test_subscription(session, attendee, course_event): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,13 @@ def assert_last_modified(): | |
|
||
client_with_es.login('[email protected]', 'hunter2') | ||
|
||
page = client_with_es.get('/').click('Landsgemeinden') | ||
page = client_with_es.get('/').click('Archiv') | ||
assert 'Noch keine Landsgemeinden erfasst.' in page | ||
assert 'Zum Liveticker' not in page | ||
|
||
# add assembly | ||
with freeze_time('2023-05-07 9:30'): | ||
page = page.click('Landsgemeinde', index=1) | ||
page = page.click('Landsgemeinde') | ||
page.form['date'] = '2023-05-07' | ||
page.form['state'] = 'ongoing' | ||
page.form['overview'] = '<p>Lorem ipsum</p>' | ||
|
@@ -167,15 +167,15 @@ def assert_last_modified(): | |
# delete agenda item | ||
with freeze_time('2023-05-07 9:37'): | ||
page.click('Löschen') | ||
page = page.click('Landsgemeinde', index=2) | ||
page = page.click('Landsgemeinde', index=1) | ||
assert '<p>Lorem ipsum dolor sit amet</p>' in page | ||
assert 'A. consectetur adipiscing' not in page | ||
assert_last_modified() | ||
|
||
# delete landsgemeinde | ||
with freeze_time('2023-05-07 9:38'): | ||
page.click('Löschen') | ||
page = page.click('Landsgemeinden', index=0) | ||
page = page.click('Archiv', index=0) | ||
assert 'Noch keine Landsgemeinden erfasst.' in page | ||
|
||
|
||
|
@@ -189,8 +189,8 @@ def test_view_pages_cache(landsgemeinde_app): | |
|
||
# add assembly | ||
client.login('[email protected]', 'hunter2') | ||
page = client.get('/').click('Landsgemeinden') | ||
page = page.click('Landsgemeinde', index=1) | ||
page = client.get('/').click('Archiv') | ||
page = page.click('Landsgemeinde') | ||
page.form['date'] = '2023-05-07' | ||
page.form['state'] = 'completed' | ||
page.form['overview'] = 'Lorem' | ||
|