コード例 #1
0
    def test_invalid_add_resident_to_room(self):
        """ Tests that non-resident users cannot be added to a room """
        test_user_info = ('*****@*****.**', 'Bob', 'Ross', 'ADMIN')
        test_user = UserService.create_user(*test_user_info)

        with self.assertRaises(ValueError):
            RoomService.add_resident_to_room(test_user.email,
                                             self.test_room.number)

        resident = ResidentService.get_resident_by_id(test_user.id)

        self.assertIsNone(resident)
        self.assertFalse(resident in self.test_room.occupants)
コード例 #2
0
    def test_add_resident_to_room(self):
        """ Tests that residents can be added to a room """
        test_user_info = ('*****@*****.**', 'Bob', 'Ross', 'RESIDENT')
        test_user = UserService.create_user(*test_user_info)
        resident = ResidentService.get_resident_by_id(test_user.id)
        old_room = RoomService.get_room_by_number('')

        self.assertTrue(resident in old_room.occupants)
        RoomService.add_resident_to_room(test_user.email,
                                         self.test_room.number)

        self.assertEqual(resident.room_number, self.test_room.number)
        self.assertTrue(resident in self.test_room.occupants)
        self.assertFalse(resident in old_room.occupants)
コード例 #3
0
    def edit_resident(user_id, email, first_name, last_name, room_number):
        """
        Edits an existing resident identified by user_id.

        Args:
            user_id: Unique user id.
            email: New email.
            first_name: New first name.
            last_name: New last name.
            room_number: New room number.
        """
        from ovs.services.user_service import UserService
        from ovs.services.room_service import RoomService
        UserService.edit_user(user_id, email, first_name, last_name)
        RoomService.add_resident_to_room(email, room_number)