Exemplo n.º 1
0
    def test_assign_lab_not_logged_in(self):
        course_number = "361"
        lab_number = "801"
        assign_command = AssignLab(self.environment)
        response = assign_command.action(
            ["assign_lab", course_number, lab_number, "apoorv"])

        self.assertFalse(assign_command.lab_assigned(course_number,
                                                     lab_number))
        self.assertEqual(response, "Error assigning to lab.")
Exemplo n.º 2
0
    def test_assign_lab_correct_args_and_permissions(self):
        self.environment.user = User("jayson", "instructor")

        course_number = "361"
        lab_number = "801"
        assign_command = AssignLab(self.environment)
        response = assign_command.action(
            ["assign_lab", course_number, lab_number, "apoorv"])

        self.assertTrue(assign_command.lab_assigned(course_number, lab_number))
        self.assertEqual(response, "Assigned to lab.")
Exemplo n.º 3
0
    def test_assign_lab_to_nonexistant_user(self):
        self.environment.user = User("root", "administrator")

        course_number = "361"
        lab_number = "801"
        assign_command = AssignLab(self.environment)
        response = assign_command.action(
            ["assign_lab", course_number, lab_number, "IDontExist"])

        self.assertFalse(assign_command.lab_assigned(course_number,
                                                     lab_number))
        self.assertEqual(response, "Error assigning to lab.")
Exemplo n.º 4
0
    def test_assign_lab_that_doesnt_exist(self):
        self.environment.user = User("root", "administrator")

        course_number = "361"
        lab_number = "888"
        assign_command = AssignLab(self.environment)
        response = assign_command.action(
            ["assign_lab", course_number, lab_number, "apoorv"])

        self.assertFalse(assign_command.lab_assigned(course_number,
                                                     lab_number))
        self.assertEqual(response, "Error assigning to lab.")
Exemplo n.º 5
0
    def test_assign_lab_no_permissions(self):
        self.environment.user = User("apoorv", "TA")

        course_number = "361"
        lab_number = "801"
        assign_command = AssignLab(self.environment)
        response = assign_command.action(
            ["assign_lab", course_number, lab_number, "apoorv"])

        self.assertFalse(assign_command.lab_assigned(course_number,
                                                     lab_number))
        self.assertEqual(response, "Error assigning to lab.")
Exemplo n.º 6
0
    def test_assign_lab_to_not_a_ta(self):
        self.environment.user = User("root", "administrator")
        self.environment.database.create_account("jayson", "password",
                                                 "instructor")

        course_number = "361"
        lab_number = "801"
        assign_command = AssignLab(self.environment)
        response = assign_command.action(
            ["assign_lab", course_number, lab_number, "jayson"])

        self.assertFalse(assign_command.lab_assigned(course_number,
                                                     lab_number))
        self.assertEqual(response, "Error assigning to lab.")
Exemplo n.º 7
0
    def test_assign_lab_that_already_assigned(self):
        self.environment.user = User("root", "administrator")

        course_number = "361"
        lab_number = "801"

        assign_command = AssignLab(self.environment)
        self.environment.database.set_lab_assignment(course_number, lab_number,
                                                     "apoorv")
        self.assertTrue(assign_command.lab_assigned(course_number, lab_number))

        response = assign_command.action(
            ["assign_lab", course_number, lab_number, "apoorv"])

        self.assertEqual(response, "Error assigning to lab.")