예제 #1
0
 def test_two_slots_one_session(self):
     # If there are two slots, we return data for each of them, in order of the slots
     # start time
     user1 = UserFactory(first_name="Melanie",
                         last_name="Pickle",
                         email='*****@*****.**')
     user2 = UserFactory(first_name="Ichabod",
                         last_name="Crane",
                         email='*****@*****.**')
     session = SessionFactory()
     slot1 = SlotFactory(start=datetime.time(13))
     slot2 = SlotFactory(start=datetime.time(8))
     session.slots.add(slot1)
     session.slots.add(slot2)
     SessionRoleFactory(session=session,
                        user=user1,
                        role=SessionRole.SESSION_ROLE_CHAIR)
     SessionRoleFactory(session=session,
                        user=user2,
                        role=SessionRole.SESSION_ROLE_CHAIR,
                        status=False)
     data = self.get_api_result()
     self.assertEqual([{
         'conf_key': slot2.pk,
         'chair_email': '*****@*****.**',
         'chair_name': 'Melanie Pickle',
         'runner_email': '',
         'runner_name': ''
     }, {
         'conf_key': slot1.pk,
         'chair_email': '*****@*****.**',
         'chair_name': 'Melanie Pickle',
         'runner_email': '',
         'runner_name': ''
     }], data)
예제 #2
0
 def test_two_slots_two_sessions(self):
     # If there are two slots, we return data for each of them, in order of the slots
     # start time
     user1 = UserFactory(first_name="Melanie",
                         last_name="Pickle",
                         email='*****@*****.**')
     user2 = UserFactory(first_name="Ichabod",
                         last_name="Crane",
                         email='*****@*****.**')
     session1 = SessionFactory()
     session2 = SessionFactory()
     slot1 = SlotFactory(start=datetime.time(13))
     slot2 = SlotFactory(start=datetime.time(8))
     session1.slots.add(slot1)
     session2.slots.add(slot2)
     SessionRoleFactory(session=session1,
                        user=user1,
                        role=SessionRole.SESSION_ROLE_CHAIR)
     SessionRoleFactory(session=session1,
                        user=user2,
                        role=SessionRole.SESSION_ROLE_RUNNER)
     user3 = UserFactory(first_name="Mike",
                         last_name="Hammer",
                         email='*****@*****.**')
     user4 = UserFactory(first_name="Sam",
                         last_name="Spade",
                         email='*****@*****.**')
     SessionRoleFactory(session=session2,
                        user=user3,
                        role=SessionRole.SESSION_ROLE_CHAIR)
     SessionRoleFactory(session=session2,
                        user=user4,
                        role=SessionRole.SESSION_ROLE_RUNNER)
     data = self.get_api_result()
     self.assertEqual([{
         'conf_key': slot2.pk,
         'chair_email': '*****@*****.**',
         'chair_name': 'Mike Hammer',
         'runner_email': '*****@*****.**',
         'runner_name': 'Sam Spade'
     }, {
         'conf_key': slot1.pk,
         'chair_email': '*****@*****.**',
         'chair_name': 'Melanie Pickle',
         'runner_email': '*****@*****.**',
         'runner_name': 'Ichabod Crane'
     }], data)
예제 #3
0
 def test_slot_no_roles(self):
     session = SessionFactory()
     slot = SlotFactory()
     session.slots.add(slot)
     data = self.get_api_result()
     self.assertEqual([{
         'conf_key': slot.pk,
         'chair_email': '',
         'chair_name': '',
         'runner_email': '',
         'runner_name': ''
     }], data)
예제 #4
0
 def test_slot_runner_no_chair(self):
     user = UserFactory(first_name="Melanie",
                        last_name="Pickle",
                        email='*****@*****.**')
     session = SessionFactory()
     slot = SlotFactory()
     session.slots.add(slot)
     SessionRoleFactory(session=session,
                        user=user,
                        role=SessionRole.SESSION_ROLE_RUNNER)
     data = self.get_api_result()
     self.assertEqual([{
         'conf_key': slot.pk,
         'chair_email': '',
         'chair_name': '',
         'runner_email': '*****@*****.**',
         'runner_name': 'Melanie Pickle',
     }], data)
예제 #5
0
 def test_two_chairs_two_runners_one_declined(self):
     user1 = UserFactory(first_name="Melanie",
                         last_name="Pickle",
                         email='*****@*****.**')
     user2 = UserFactory(first_name="Ichabod",
                         last_name="Crane",
                         email='*****@*****.**')
     session = SessionFactory()
     slot = SlotFactory()
     session.slots.add(slot)
     SessionRoleFactory(session=session,
                        user=user1,
                        role=SessionRole.SESSION_ROLE_CHAIR)
     SessionRoleFactory(session=session,
                        user=user2,
                        role=SessionRole.SESSION_ROLE_CHAIR,
                        status=False)
     user3 = UserFactory(first_name="Mike",
                         last_name="Hammer",
                         email='*****@*****.**')
     user4 = UserFactory(first_name="Sam",
                         last_name="Spade",
                         email='*****@*****.**')
     SessionRoleFactory(session=session,
                        user=user3,
                        role=SessionRole.SESSION_ROLE_RUNNER)
     SessionRoleFactory(session=session,
                        user=user4,
                        role=SessionRole.SESSION_ROLE_RUNNER,
                        status=False)
     data = self.get_api_result()
     self.assertEqual([{
         'conf_key': slot.pk,
         'chair_email': '*****@*****.**',
         'chair_name': 'Melanie Pickle',
         'runner_email': '*****@*****.**',
         'runner_name': 'Mike Hammer'
     }], data)
예제 #6
0
 def test_slot_chair_and_runner(self):
     user1 = UserFactory(first_name="Melanie",
                         last_name="Pickle",
                         email='*****@*****.**')
     user2 = UserFactory(first_name="Ichabod",
                         last_name="Crane",
                         email='*****@*****.**')
     session = SessionFactory()
     slot = SlotFactory()
     session.slots.add(slot)
     SessionRoleFactory(session=session,
                        user=user1,
                        role=SessionRole.SESSION_ROLE_CHAIR)
     SessionRoleFactory(session=session,
                        user=user2,
                        role=SessionRole.SESSION_ROLE_RUNNER)
     data = self.get_api_result()
     self.assertEqual([{
         'conf_key': slot.pk,
         'chair_email': '*****@*****.**',
         'chair_name': 'Melanie Pickle',
         'runner_email': '*****@*****.**',
         'runner_name': 'Ichabod Crane',
     }], data)
예제 #7
0
 def test_empty_session(self):
     self.session = SessionFactory()
     data = self.get_api_result()
     self.assertEqual(0, len(data))