52 lines
2.4 KiB
Python
52 lines
2.4 KiB
Python
# Copyright The IETF Trust 2021, All Rights Reserved
|
|
# -*- coding: utf-8 -*-
|
|
"""Tests of models in the Meeting application"""
|
|
from ietf.meeting.factories import MeetingFactory
|
|
from ietf.stats.factories import MeetingRegistrationFactory
|
|
from ietf.utils.test_utils import TestCase
|
|
|
|
|
|
class MeetingTests(TestCase):
|
|
def test_get_attendance_pre110(self):
|
|
"""Pre-110 meetings do not calculate attendance"""
|
|
meeting = MeetingFactory(type_id='ietf', number='109')
|
|
MeetingRegistrationFactory.create_batch(3, meeting=meeting, reg_type='')
|
|
MeetingRegistrationFactory.create_batch(4, meeting=meeting, reg_type='remote')
|
|
MeetingRegistrationFactory.create_batch(5, meeting=meeting, reg_type='in_person')
|
|
self.assertIsNone(meeting.get_attendance())
|
|
|
|
def test_get_attendance(self):
|
|
"""Post-110 meetings do calculate attendance"""
|
|
meeting = MeetingFactory(type_id='ietf', number='110')
|
|
|
|
# start with attendees that should be ignored
|
|
MeetingRegistrationFactory.create_batch(3, meeting=meeting, reg_type='')
|
|
MeetingRegistrationFactory(meeting=meeting, reg_type='', attended=False)
|
|
attendance = meeting.get_attendance()
|
|
self.assertIsNotNone(attendance)
|
|
self.assertEqual(attendance.online, 0)
|
|
self.assertEqual(attendance.onsite, 0)
|
|
|
|
# add online attendees with at least one who registered but did not attend
|
|
MeetingRegistrationFactory.create_batch(4, meeting=meeting, reg_type='remote')
|
|
MeetingRegistrationFactory(meeting=meeting, reg_type='remote', attended=False)
|
|
attendance = meeting.get_attendance()
|
|
self.assertIsNotNone(attendance)
|
|
self.assertEqual(attendance.online, 4)
|
|
self.assertEqual(attendance.onsite, 0)
|
|
|
|
# and the same for onsite attendees
|
|
MeetingRegistrationFactory.create_batch(5, meeting=meeting, reg_type='in_person')
|
|
MeetingRegistrationFactory(meeting=meeting, reg_type='in_person', attended=False)
|
|
attendance = meeting.get_attendance()
|
|
self.assertIsNotNone(attendance)
|
|
self.assertEqual(attendance.online, 4)
|
|
self.assertEqual(attendance.onsite, 5)
|
|
|
|
# and once more after removing all the online attendees
|
|
meeting.meetingregistration_set.filter(reg_type='remote').delete()
|
|
attendance = meeting.get_attendance()
|
|
self.assertIsNotNone(attendance)
|
|
self.assertEqual(attendance.online, 0)
|
|
self.assertEqual(attendance.onsite, 5)
|