Ejemplo n.º 1
0
 def test_create_lab_invalid_days(self):
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_days),
                      "Invalid days of the week, please enter days in the format: MWTRF")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_days2),
                      "Invalid days of the week, please enter days in the format: MWTRF")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_days3),
                      "Invalid days of the week, please enter days in the format: MWTRF")
Ejemplo n.º 2
0
    def test_lab_was_successfully_created(self):
        self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab), "Lab successfully created")
        self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_multiple_section),
                         "Lab successfully created")
        self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab2), "Lab successfully created")
        self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_multiple_section2),
                         "Lab successfully created")

        a = Lab.objects.get(course=self.c2, sectionNumber=201)
        self.assertEqual(a.course, self.c2)
        self.assertEqual(a.sectionNumber, 201)
        self.assertEqual(a.meetingDays, "T")
        self.assertEqual(a.startTime, 1000)
        self.assertEqual(a.endTime, 1100)

        b = Lab.objects.get(course=self.c2, sectionNumber=202)
        self.assertEqual(b.course, self.c2)
        self.assertEqual(b.sectionNumber, 202)
        self.assertEqual(b.meetingDays, "W")
        self.assertEqual(b.startTime, 1300)
        self.assertEqual(b.endTime, 1400)

        c = Lab.objects.get(course=self.c3, sectionNumber=201)
        self.assertEqual(c.course, self.c3)
        self.assertEqual(c.sectionNumber, 201)
        self.assertEqual(c.meetingDays, "R")
        self.assertEqual(c.startTime, 1200)
        self.assertEqual(c.endTime, 1345)

        d = Lab.objects.get(course=self.c2, sectionNumber=203)
        self.assertEqual(d.course, self.c2)
        self.assertEqual(d.sectionNumber, 203)
        self.assertEqual(d.meetingDays, "F")
        self.assertEqual(d.startTime, 1100)
        self.assertEqual(d.endTime, 1245)
Ejemplo n.º 3
0
 def test_create_lab_invalid_sectNum(self):
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_sectNum),
                      "Section number must be numeric and three digits long")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_sectNum2),
                      "Section number must be numeric and three digits long")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_sectNum3),
                      "Section number must be numeric and three digits long")
Ejemplo n.º 4
0
 def setUp(self):
     self.login = LoginHelper()
     self.CUH = CurrentUserHelper()
     self.CA = CreateAccount()
     self.CC = CreateCourse()
     self.CL = CreateLab()
     self.account1 = Account.objects.create(firstName='Homer',
                                            userName='******',
                                            password='******')
     self.account2 = Account.objects.create(firstName='Stu',
                                            userName='******',
                                            password='******')
     self.course1 = Course.objects.create(name='Eng',
                                          number='101',
                                          onCampus='True',
                                          classDays='W')
Ejemplo n.º 5
0
 def test_create_lab_invalid_times(self):
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_time),
                      "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_time2),
                      "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_time3),
                      "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_time4),
                      "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_time5),
                      "Invalid start or end time, please use a 4 digit military time representation")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_invalid_time6),
                      "Invalid start or end time, please use a 4 digit military time representation")
Ejemplo n.º 6
0
 def test_lab_missing_arguments(self):
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_no_args),
                      "Your command is missing arguments, please enter your command in the following format: "
                      "createLab courseNumber labSectionNumber daysOfWeek beginTime endTime")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_no_courseNumber),
                      "Your command is missing arguments, please enter your command in the following format: "
                      "createLab courseNumber labSectionNumber daysOfWeek beginTime endTime")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_no_daysOfWeek),
                      "Your command is missing arguments, please enter your command in the following format: "
                      "createLab courseNumber labSectionNumber daysOfWeek beginTime endTime")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_no_sectionNumber),
                      "Your command is missing arguments, please enter your command in the following format: "
                      "createLab courseNumber labSectionNumber daysOfWeek beginTime endTime")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_noStartTime),
                      "Your command is missing arguments, please enter your command in the following format: "
                      "createLab courseNumber labSectionNumber daysOfWeek beginTime endTime")
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_noEndTime),
                      "Your command is missing arguments, please enter your command in the following format: "
                      "createLab courseNumber labSectionNumber daysOfWeek beginTime endTime")
Ejemplo n.º 7
0
    def command(self, inStr):
        command = ' '.join(inStr.split(' '))

        command = command.split()

        if command[0].lower() == "login":
            login = LoginHelper()
            return login.login(command)

        elif command[0].lower() == "logout":
            logout = LoginHelper()
            return logout.logout()

        elif command[0].lower() == "createaccount":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 3:
                return "You do not have the credentials to create an account. Permission denied"

            CA = CreateAccount()
            return CA.createAccount(command)

        elif command[0].lower() == "createlab":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 3:
                return "You do not have the credentials to create a lab. Permission denied"

            create = CreateLab()
            return create.createLab(command)

        elif command[0].lower() == "createcourse":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 3:
                return "You do not have the credentials to create a course. Permission denied"

            create = CreateCourse()
            return create.createCourse(command)

        elif command[0].lower() == "assigninstructorcourse":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 3:
                return "You do not have the credentials to assign an instructor to a course. Permission denied"

            AIC = assignInst()

            return AIC.assignInst(command)

        elif command[0].lower() == "assigntalab":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 2:
                return "You do not have the credentials to assign a ta to a lab. Permission denied"

            atl = AssignTaLab()

            return atl.assignTaLab(command)

        elif command[0].lower() == "assigntacourse":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 3:
                return "You do not have the credentials to assign a ta to a course. Permission denied"

            TAC = AssignTACourse()

            return TAC.assignTACourse(command)

        elif command[0].lower() == "viewcourseassign":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 1:
                return "You must log in to View Course Assignment"

            return viewTaAssignments(command)

        elif command[0].lower() == "deleteaccount":
            CUH = CurrentUserHelper()
            if CUH.getCurrentUserTitle() < 3:
                return "You do not have the credentials to delete an account. Permission denied"

            DA = DeleteAccount()
            return DA.createAccount(command)

        else:
            return command[0] + " is an unsupported command"
Ejemplo n.º 8
0
    def setUp(self):
        self.CL = CreateLab()

        # Create courses to test against
        Course.objects.create(name="TemporalMechanics", number=784, onCampus=True, classDays="MW",
                              classHoursStart=1000, classHoursEnd=1100)

        Course.objects.create(name="WarpTheory", number=633, onCampus=True, classDays="TR", classHoursStart=1200,
                              classHoursEnd=1250)

        Course.objects.create(name="QuantumMechanics", number=709, onCampus=True, classDays="MWF",
                              classHoursStart=1030, classHoursEnd=1145)

        Course.objects.create(name="Linguistics", number=564, onCampus=False, classDays="TR",
                              classHoursStart=1800, classHoursEnd=1930)

        # Assigns the courses to variables
        self.c1 = Course.objects.get(name="TemporalMechanics")
        self.c2 = Course.objects.get(name="WarpTheory")
        self.c3 = Course.objects.get(name="QuantumMechanics")

        # Create some labs to test against
        Lab.objects.create(course=self.c1, sectionNumber=201, meetingDays="W", startTime=1000, endTime=1200)
        Lab.objects.create(course=self.c1, sectionNumber=202, meetingDays="F", startTime=1400, endTime=1700)
        Lab.objects.create(course=self.c1, sectionNumber=203, meetingDays="T", startTime=1000, endTime=1200)

        # Commands to tests that a lab can be created
        self.command_create_lab = ["createLab", "633", "201", "T", "1000", "1100"]
        self.command_create_lab_multiple_section = ["createLab", "633", "202", "W", "1300", "1400"]
        self.command_create_lab_multiple_section2 = ["createLab", "633", "203", "F", "1100", "1245"]
        self.command_create_lab2 = ["createLab", "709", "201", "R", "1200", "1345"]

        # Commands to test that a lab that already exists can't be created
        self.command_section_exists = ["createLab", "784", "201", "W", "1000", "1200"]

        # Commands to test missing arguments
        self.command_create_lab_no_args = ["createLab"]
        self.command_create_lab_no_courseNumber = ["createLab", "001", "W", "1000", "1200"]
        self.command_create_lab_no_sectionNumber = ["createLab", "540", "W", "1000", "1200"]
        self.command_create_lab_no_daysOfWeek = ["createlab", "540", "001", "1000", "1200"]
        self.command_create_lab_noStartTime = ["createLab", "540", "001", "W", "1200"]
        self.command_create_lab_noEndTime = ["createLab", "540", "001", "W", "1000"]

        # Commands to test that a lab cannot be created for a course that doesn't exist
        self.command_create_lab_courseDoesNotExist = ["createLab", "540", "001", "W", "1000", "1200"]

        # Commands to test if an invalid course number is entered
        self.command_create_lab_invalid_courseNum = ["createLab", "abc", "201", "M", "1300", "1600"]
        self.command_create_lab_invalid_courseNum2 = ["createLab", "3b0", "201", "M", "1300", "1600"]
        self.command_create_lab_invalid_courseNum3 = ["createLab", "123456", "201", "M", "1300", "1600"]

        # Commands to test if an invalid section number is entered
        self.command_create_lab_invalid_sectNum = ["createLab", "633", "abc", "M", "1300", "1600"]
        self.command_create_lab_invalid_sectNum2 = ["createLab", "633", "2a1", "M", "1300", "1600"]
        self.command_create_lab_invalid_sectNum3 = ["createLab", "633", "20981", "M", "1300", "1600"]

        # Commands to test if meeting days are valid
        self.command_create_lab_invalid_days = ["createLab", "633", "201", "q", "1300", "1600"]
        self.command_create_lab_invalid_days2 = ["createLab", "633", "401", "12", "1300", "1600"]
        self.command_create_lab_invalid_days3 = ["createLab", "633", "301", "MWy", "1300", "1600"]

        # Commands to test if times are valid
        self.command_create_lab_invalid_time = ["createLab", "633", "201", "T", "a", "1600"]
        self.command_create_lab_invalid_time2 = ["createLab", "633", "401", "TR", "1300", "apouy"]
        self.command_create_lab_invalid_time3 = ["createLab", "633", "301", "MWF", "130034", "1600"]
        self.command_create_lab_invalid_time4 = ["createLab", "633", "201", "T", "789uasd", "1600"]
        self.command_create_lab_invalid_time5 = ["createLab", "633", "401", "TR", "1300", "9999999"]
        self.command_create_lab_invalid_time6 = ["createLab", "633", "301", "MWF", "1300", "16"]

        # Command to make sure a lab cannot be created for an online course
        self.command_create_lab_online = ["createLab", "564", "201", "R", "1300", "1500"]
Ejemplo n.º 9
0
 def test_cannot_create_for_online(self):
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_online),
                      "You cannot create a lab for an online course")
Ejemplo n.º 10
0
 def test_courseDoesNotExist(self):
     self.assertEqual(CreateLab.createLab(self.CL, self.command_create_lab_courseDoesNotExist),
                      "The Course you are trying to create a lab for does not exist")
Ejemplo n.º 11
0
 def test_section_already_exists(self):
     self.assertEqual((CreateLab.createLab(self.CL, self.command_section_exists)),
                      "Lab already exists, lab not added")
Ejemplo n.º 12
0
class TestIntegration(TestCase):
    def setUp(self):
        self.login = LoginHelper()
        self.CUH = CurrentUserHelper()
        self.CA = CreateAccount()
        self.CC = CreateCourse()
        self.CL = CreateLab()
        self.account1 = Account.objects.create(firstName='Homer',
                                               userName='******',
                                               password='******')
        self.account2 = Account.objects.create(firstName='Stu',
                                               userName='******',
                                               password='******')
        self.course1 = Course.objects.create(name='Eng',
                                             number='101',
                                             onCampus='True',
                                             classDays='W')

    def test00(self):
        # test login
        self.assertEqual(self.login.login(["login", "Homer", "123456"]),
                         "Account Not Found")

        self.assertFalse(self.CUH.isCurrent())

        self.assertEqual(self.login.login(["login", "hsimpson", "123456"]),
                         "Logged in as hsimpson")

        self.assertTrue(self.CUH.isCurrent())

    def test01(self):
        # test login with logout
        self.assertFalse(self.CUH.isCurrent())

        self.assertEqual(self.login.login(["login", "hsimpson", '123456']),
                         "Logged in as hsimpson")

        self.assertTrue(self.CUH.isCurrent())

        self.assertEqual(self.login.logout(), "Successfully logged out")

        self.assertFalse(self.CUH.isCurrent())

    def test02(self):
        # test create account login
        self.assertEqual(Account.objects.count(), 2)

        self.assertEqual(
            self.CA.createAccount(
                ["createaccount", "taman", "ta", "*****@*****.**"]),
            "Account successfully created.  Temporary password is: taman456")

        self.assertEqual(Account.objects.count(), 3)

        self.assertFalse(self.CUH.isCurrent())

        self.assertEqual(self.login.login(["login", "taman", "taman456"]),
                         "Logged in as taman")

        self.assertEqual(self.CUH.getCurrentUser(),
                         Account.objects.get(userName='******'))

        self.assertTrue(self.CUH.isCurrent())

        self.assertEqual(self.CUH.getCurrentUserTitle(), 1)

        self.assertEqual(self.login.logout(), "Successfully logged out")

        self.assertFalse(self.CUH.isCurrent())

    def test03(self):
        # test creating accounts with same username
        self.assertEqual(Account.objects.count(), 2)

        self.assertEqual(
            self.CA.createAccount(
                ["createaccount", "hsimpson", "password", "*****@*****.**"]),
            "Account already exists")

        self.assertEqual(Account.objects.count(), 2)

        self.assertEqual(
            self.CA.createAccount(
                ["createaccount", "spidface", "password", "*****@*****.**"]),
            "Account already exists")

        self.assertEqual(Account.objects.count(), 2)

    def test04(self):
        # test creating Courses
        self.assertEqual(Course.objects.count(), 1)

        self.assertEqual(
            self.CC.createCourse(
                ["createCourse", "Eng", "101", "Campus", "TR", "1000",
                 "1050"]), "Course already exists")

        self.assertEqual(Course.objects.count(), 1)

        self.assertEqual(
            self.CC.createCourse(
                ["createCourse", "Eng", "102", "Campus", "TR", "1000",
                 "1050"]), "Course successfully created")

        self.assertEqual(Course.objects.count(), 2)

    def test05(self):
        # test creating Labs
        self.assertEqual(Lab.objects.count(), 0)

        self.assertEqual(
            self.CL.createLab(["", "101", "801", "R", "1200", "1201"]),
            "Lab successfully created")

        self.assertEqual(Lab.objects.count(), 1)

        self.assertEqual(
            self.CL.createLab(["", "101", "801", "R", "1200", "1201"]),
            "Lab already exists, lab not added")

        self.assertEqual(Lab.objects.count(), 1)

    def test06(self):
        # test creating Labs and Courses

        self.assertEqual(Lab.objects.count(), 0)

        self.assertEqual(
            self.CL.createLab(["", "351", "801", "R", "1200", "1201"]),
            "The Course you are trying to create a lab for does not exist")

        self.assertEqual(Lab.objects.count(), 0)
        self.assertEqual(Course.objects.count(), 1)

        self.assertEqual(
            self.CC.createCourse([
                "createCourse", "DataStructures", "351", "Campus", "TR",
                "1000", "1050"
            ]), "Course successfully created")

        self.assertEqual(Course.objects.count(), 2)

        self.assertEqual(
            self.CL.createLab(["", "351", "801", "R", "1200", "1201"]),
            "Lab successfully created")
        self.assertEqual(Lab.objects.count(), 1)