Esempio n. 1
0
class ValidateTests(TestCase):

    def setUp(self):
        self.worker = CommandWorker()
        User.objects.create(email="*****@*****.**", firstName='John', lastName='Henry')
        User.objects.create(email="*****@*****.**", firstName='Jane', lastName='Doe')
        cs250 = Course.objects.create(name="CS250", section="001", dates="TR", startTime='11:00:00', endTime='11:55:00')
        cs251 = Course.objects.create(name="CS251", section="001", dates="MW", startTime='13:00:00', endTime='14:00:00')
        cs482 = Course.objects.create(name="CS482", section="001", dates="Online")
        cs250.graderTAs.add(User.objects.get(email="*****@*****.**"))
        cs251.graderTAs.add(User.objects.get(email="*****@*****.**"))
        cs482.graderTAs.add(User.objects.get(email="*****@*****.**"))

    def test_valid(self):
        ret = self.worker.executeCommand("validate")
        self.assertEqual("TA assignments are valid", ret)

    def test_invalid_1(self):
        ph120 = Course.objects.create(name="PH120", section="001", dates="TR", startTime='10:00:00', endTime='11:15:00')
        ph120.graderTAs.add(User.objects.get(email="*****@*****.**"))
        ret = self.worker.executeCommand("validate")
        self.assertEqual("Error: Overlapping TAs found in conflicting course times for <CS250> and <PH120>.", ret)

    def test_invalid_2(self):
        ph122 = Course.objects.create(name="PH122", section="001", dates="MW", startTime='13:45:00', endTime='14:30:00')
        ph122.graderTAs.add(User.objects.get(email="*****@*****.**"))
        ret = self.worker.executeCommand("validate")
        self.assertEqual("Error: Overlapping TAs found in conflicting course times for <CS251> and <PH122>.", ret)
class CreateLabTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.worker.currentUser = self.admin
        self.prof = User.objects.create(email='*****@*****.**', role=2)
        self.ta = User.objects.create(email='*****@*****.**', role=1)
        self.course1 = Course.objects.create(name='CS351', section="001")
        self.lab1 = Lab.objects.create(course=self.course1, section="801")

    def test_create_lab_1(self):
        msg = self.worker.executeCommand("create lab " + self.course1.name +
                                         " 802")
        self.assertEqual("Lab Added", msg)

    def test_create_lab_2(self):
        msg = self.worker.executeCommand("create lab " + self.course1.name +
                                         " 801")
        self.assertEqual("Lab Already Exists", msg)

    def test_create_lab_3(self):
        msg = self.worker.executeCommand("create lab " + self.course1.name +
                                         " 801 asdfasdf")
        self.assertEqual("Invalid number of parameters", msg)

    def test_create_lab_4(self):
        msg = self.worker.executeCommand("create lab " + self.course1.name +
                                         " 801 asdfasdf asdfasdf")
        self.assertEqual("Invalid number of parameters", msg)

    def test_create_lab_5(self):
        msg = self.worker.executeCommand("create lab " + self.course1.name)
        self.assertEqual("Invalid number of parameters", msg)

    def test_create_lab_6(self):
        self.worker.currentUser = self.prof
        msg = self.worker.executeCommand("create lab " + self.course1.name +
                                         " 802")
        self.assertEqual("Only an Administrator can create a lab", msg)

    def test_create_lab_7(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand("create lab " + self.course1.name +
                                         " 802")
        self.assertEqual("Only an Administrator can create a lab", msg)

    def test_create_lab_8(self):
        self.worker.currentUser = self.prof
        msg = self.worker.executeCommand("create lab " + self.course1.name)
        self.assertEqual("Only an Administrator can create a lab", msg)

    def test_create_lab_9(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand("create lab " + self.course1.name)
        self.assertEqual("Only an Administrator can create a lab", msg)
class EditUserTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.ta = User.objects.create(email='*****@*****.**',
                                      firstName='Alec',
                                      lastName='Schley',
                                      phone='555-555-5555',
                                      address='roof',
                                      officeHours='2pm',
                                      officeHoursDates='MW',
                                      officeLocation='EMS',
                                      role=1)
        self.prof = User.objects.create(email='*****@*****.**', role=2)
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.worker.currentUser = self.admin
        self.course1 = Course.objects.create(name="CS999")

    #    def test_edit_user_1(self):
    #        msg = self.worker.executeCommand("edit user [email protected] Alec Schley 555-555-5555 roof 2pm MW EMS")
    #        self.assertEqual("User updated", msg)
    #
    def test_edit_user_2(self):
        msg = self.worker.executeCommand(
            "edit user [email protected] Alec Schley 555-555-5555 roof 2pm MW EMS")
        self.assertEqual("error - User matching query does not exist.", msg)

    #    def test_edit_user_3(self):
    #        msg = self.worker.executeCommand("edit user [email protected] Alec Schley 555-555-5555 roof 2pm MW")
    #        self.assertEqual("Invalid number of parameters", msg)
    #
    #    def test_edit_user_4(self):
    #        msg = self.worker.executeCommand("edit user [email protected] Alec Schley 555-555-5555 roof 2pm MW EMS EMS")
    #        self.assertEqual("Invalid number of parameters", msg)
    #
    #    def test_edit_user_5(self):
    #        msg = self.worker.executeCommand("edit user [email protected] Alec Schley 555-555-5555 roof 2pm X EMS")
    #        self.assertEqual("Invalid date(s)", msg)

    def test_edit_user_6(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand(
            "edit user [email protected] Alec Schley 555-555-5555 roof 2pm M EMS")
        self.assertEqual("Only an Administrator can edit a user", msg)

    def test_edit_user_7(self):
        self.worker.currentUser = self.prof
        msg = self.worker.executeCommand(
            "edit user [email protected] Alec Schley 555-555-5555 roof 2pm M EMS")
        self.assertEqual("Only an Administrator can edit a user", msg)
class InvalidCommandTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()

    def test_invalid_command(self):
        msg = self.worker.executeCommand("asdfdsf")
        self.assertEqual("Not a valid command", msg)
class EpicTests(TestCase):
    def setUp(self):
        self.worker = CommandWorker()

    def test_delete_user_not_admin(self):
        self.user1 = User.objects.create(email="*****@*****.**")
        msg = self.worker.executeCommand("delete user [email protected]")
        self.assertEqual("Only Admin Can Delete User", msg)
Esempio n. 6
0
class LoginTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', password='******', role=3)
        self.ta = User.objects.create(email='*****@*****.**', password='******', role=1)
        self.worker.currentUser = self.admin

    def test_login(self):
        msg = self.worker.executeCommand("login [email protected] so_very_simple")
        self.assertEqual("Given email does not belong to an existing user", msg)

    def test_login_1(self):
        msg = self.worker.executeCommand("login [email protected] so_very_simple")
        self.assertEqual("Logged in as [email protected]", msg)

    def test_login_2(self):
        msg = self.worker.executeCommand("login [email protected] so_very_simple")
        self.assertEqual("Logged in as [email protected]", msg)
        msg = self.worker.executeCommand("logout")
        self.assertEqual("You Are Logged Out", msg)

    def test_login_3(self):
        msg = self.worker.executeCommand("login [email protected] so_very_simple")
        self.assertEqual("Logged in as [email protected]", msg)
        msg = self.worker.executeCommand("logout")
        self.assertEqual("You Are Logged Out", msg)
        msg = self.worker.executeCommand("login [email protected] password")
        self.assertEqual("Logged in as [email protected]", msg)
class WorkerTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.worker.currentUser = self.admin

    def test_worker(self):
        msg = self.worker.executeCommand("adsfasdfsdf")
        self.assertEqual(msg, "Not a valid command")
class ViewLabTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.worker.currentUser = self.admin
        self.course1 = Course.objects.create(name='CS351', section="001")
        self.lab1 = Lab.objects.create(course=self.course1, section="801")

    def test_view_lab_1(self):
        l = Lab.objects.filter(course=self.course1)
        msg = self.worker.executeCommand("view labs " + self.course1.name)
        self.assertEqual(str(l.get(0)), str(msg.get(0)))
class CreateUserTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.worker.currentUser = self.admin
        self.ta = User.objects.create(email='*****@*****.**', role=1)
        self.prof = User.objects.create(email='*****@*****.**', role=2)

    def test_create_a_user(self):
        u = User.objects.filter(email="*****@*****.**")
        self.assertEqual(u.count(), 0)
        msg = self.worker.executeCommand(
            "create user [email protected] pickles4breakfast 1")
        self.assertEqual('User Added', msg)
        self.assertEqual(u.count(), 1)

    def test_create_a_user_1(self):
        self.worker.currentUser = self.ta
        u = User.objects.filter(email="*****@*****.**")
        self.assertEqual(u.count(), 0)
        msg = self.worker.executeCommand(
            "create user [email protected] pickles4breakfast")
        self.assertEqual('Only an Administrator can create a user', msg)
        self.assertEqual(u.count(), 0)

    def test_create_a_user_2(self):
        self.worker.currentUser = self.prof
        u = User.objects.filter(email="*****@*****.**")
        self.assertEqual(u.count(), 0)
        msg = self.worker.executeCommand(
            "create user [email protected] pickles4breakfast")
        self.assertEqual('Only an Administrator can create a user', msg)
        self.assertEqual(u.count(), 0)

    def test_create_a_user_3(self):
        # u = User.objects.filter(email="*****@*****.**")
        msg = self.worker.executeCommand("create user")
        self.assertEqual("Invalid number of parameters", msg)

    def test_create_a_user_4(self):
        u = User.objects.filter(email="*****@*****.**")
        msg = self.worker.executeCommand("create user [email protected]")
        self.assertEqual("Invalid number of parameters", msg)

    def test_create_a_user_5(self):
        u = User.objects.filter(email="*****@*****.**")
        msg = self.worker.executeCommand(
            "create user [email protected] banana banana")
        self.assertEqual(
            "error - invalid literal for int() with base 10: 'banana'", msg)

    def test_create_a_user_6(self):
        u = User.objects.filter(email="*****@*****.**")
        msg = self.worker.executeCommand("create user [email protected] shiloop 1")
        self.assertEqual("User already exists", msg)
Esempio n. 10
0
class CreateCourseTest(TestCase):

    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.ta = User.objects.create(email='*****@*****.**', role=1)
        self.prof = User.objects.create(email='*****@*****.**', role=2)
        self.worker.currentUser = self.admin

    def test_create_a_course(self):
        course = Course.objects.filter(name='CS999')
        self.assertEqual(course.count(), 0)
        msg = self.worker.executeCommand("create course CS999 101")
        self.assertEqual('Course Added', msg)
        self.assertEqual(course.count(), 1)

    def test_create_a_course_1(self):
        course = Course.objects.filter(name='CS999')
        self.assertEquals(course.count(), 0)
        msg = self.worker.executeCommand("create course CS999 101 adadadad")
        self.assertEqual('Invalid number of parameters', msg)
        self.assertEqual(course.count(), 0)

    def test_create_a_course_2(self):
        course = Course.objects.filter(name='CS999')
        self.assertEqual(course.count(), 0)
        msg = self.worker.executeCommand("create course")
        self.assertEqual('Invalid number of parameters', msg)
        self.assertEqual(course.count(), 0)

    def test_create_a_course_3(self):
        course = Course.objects.filter(name='CS999')
        self.assertEquals(course.count(), 0)
        msg = self.worker.executeCommand("create course CS999 101")
        self.assertEqual('Course Added', msg)
        self.assertEqual(course.count(), 1)
        msg = self.worker.executeCommand("create course CS999 101")
        self.assertEqual('Course Already Exists', msg)
        self.assertEqual(course.count(), 1)

    def test_create_a_course_4(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand("create course CS999")
        self.assertEqual("Only an Administrator can create a course", msg)

    def test_create_a_course_5(self):
        self.worker.currentUser = self.prof
        msg = self.worker.executeCommand("create course CS999")
        self.assertEqual("Only an Administrator can create a course", msg)
class EditCourseTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.worker.currentUser = self.admin
        self.prof = User.objects.create(email='*****@*****.**', role=2)
        self.ta = User.objects.create(email='*****@*****.**', role=1)
        self.course1 = Course.objects.create(name="CS999")

    def test_edit_course_1(self):
        msg = self.worker.executeCommand(
            "edit course CS999 001 EMS180 11:00 11:55 MW")
        self.assertEqual("Course Updated", msg)

    def test_edit_course_2(self):
        msg = self.worker.executeCommand(
            "edit course CS900 001 EMS180 11:00 11:55 MW")
        self.assertEqual("error - Course matching query does not exist.", msg)

    def test_edit_course_3(self):
        msg = self.worker.executeCommand(
            "edit course CS999 001 EMS180 11:00 11:55")
        self.assertEqual("error - list index out of range", msg)

    def test_edit_course_4(self):
        msg = self.worker.executeCommand(
            "edit course CS999 001 EMS180 11:00 11:55 MW MW")
        self.assertEqual("Invalid number of parameters", msg)

    def test_edit_course_5(self):
        msg = self.worker.executeCommand(
            "edit course CS999 001 EMS180 11:00 11:55 X")
        self.assertEqual("Invalid date(s)", msg)

    def test_edit_course_6(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand(
            "edit course CS999 001 EMS180 11:00 11:55 M")
        self.assertEqual("Only an Administrator can edit a course", msg)

    def test_edit_course_7(self):
        self.worker.currentUser = self.prof
        msg = self.worker.executeCommand(
            "edit course CS999 001 EMS180 11:00 11:55 M")
        self.assertEqual("Only an Administrator can edit a course", msg)
Esempio n. 12
0
class EditLabTest(TestCase):
    def setUp(self):
        self.worker = CommandWorker()
        self.admin = User.objects.create(email='*****@*****.**', role=3)
        self.worker.currentUser = self.admin
        self.prof = User.objects.create(email='*****@*****.**', role=2)
        self.ta = User.objects.create(email='*****@*****.**', role=1)
        self.course1 = Course.objects.create(name='CS351', section="001")
        self.lab1 = Lab.objects.create(course=self.course1, section="801")


    def test_edit_lab_1(self):
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50 M")
        self.assertEqual("Lab Updated", msg)

    def test_edit_lab_2(self):
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50")
        self.assertEqual("Invalid number of parameters", msg)

    def test_edit_lab_3(self):
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50 M M")
        self.assertEqual("Invalid number of parameters", msg)

    def test_edit_lab_4(self):
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50 MX")
        self.assertEqual("Invalid date(s)", msg)

    def test_edit_lab_5(self):
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50 Online")
        self.assertEqual("Lab Updated", msg)

    def test_edit_lab_6(self):
        self.worker.currentUser = self.prof
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50 M")
        self.assertEqual("Only an Administrator can edit a lab", msg)

    def test_edit_lab_7(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50 M")
        self.assertEqual("Only an Administrator can edit a lab", msg)

    def test_edit_lab_8(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50")
        self.assertEqual("Only an Administrator can edit a lab", msg)

    def test_edit_lab_9(self):
        self.worker.currentUser = self.ta
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 801 hell 11:00 11:50")
        self.assertEqual("Only an Administrator can edit a lab", msg)

    def test_edit_lab_10(self):
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 802 hell 11:00 11:50 M")
        self.assertEqual("error - Lab matching query does not exist.", msg)

    def test_edit_lab_11(self):
        msg = self.worker.executeCommand("edit lab " + self.course1.name + " 803 hell 11:00 11:50 M")
        self.assertEqual("error - Lab matching query does not exist.", msg)