Example #1
0
    def test_delete_user_null(self):
        """ Tests that nothing breaks when deleting a nonexistant resident """
        expected = User.query.count()

        # This id is NOT the resident
        with self.assertRaises(AttributeError):
            UserService.delete_user(self.test_user.id + 1)

        self.assertEqual(User.query.count(), expected)
Example #2
0
    def test_delete_user(self):
        """ Tests that a user can be deleted """

        user = UserService.create_user('*****@*****.**', '', '', 'STAFF')
        expected = User.query.count() - 1

        # check if deletion successful
        UserService.delete_user(user.id)

        self.assertEqual(expected, User.query.count())
Example #3
0
    def test_delete_user_resident(self):
        """ Tests that deleting a user deletes their resident info """
        resident = UserService.create_user('*****@*****.**', 'John', 'Smith',
                                           'RESIDENT')
        expected_user = User.query.count() - 1
        expected_resident = Resident.query.count() - 1

        UserService.delete_user(resident.id)

        self.assertEqual(User.query.count(), expected_user)
        self.assertEqual(Resident.query.count(), expected_resident)
Example #4
0
    def test_delete_user_last_admin(self):
        """ Tests that a user can be deleted """
        expected = self.db.session.query(User).count()

        # check if deletion successful
        self.assertFalse(UserService.delete_user(self.test_user.id))

        self.assertEqual(self.db.session.query(User).count(), expected)