コード例 #1
0
    def test_get_assignment(self):
        assignment1 = classroom_manager.Assignment("Assignment 1", 100)
        assignment2 = classroom_manager.Assignment("Quiz 1", 50)
        student = classroom_manager.Student(1234, "Hannah", "Pittman")

        self.assertEqual(student.get_assignment("Quiz 1"),
                         None)  # no assignments to look at
        student.assignments = [assignment1, assignment2]
        self.assertEqual(student.get_assignment("Quiz 1"),
                         student.assignments[1])  # assignment at index 1
コード例 #2
0
    def test_submit_assignnment(self):
        assignment1 = classroom_manager.Assignment("Assignment 1", 100)
        assignment2 = classroom_manager.Assignment("Quiz 1", 50)
        student = classroom_manager.Student(1234, "Hannah", "Pittman")
        student.assignments = [assignment1, assignment2]

        assignment3 = "Homework 1"
        student.submit_assignment(assignment3)

        self.assertEqual(len(student.assignments), 3)
コード例 #3
0
    def test_get_average(self):
        student = classroom_manager.Student(1234, "Hannah", "Pittman")
        assignment1 = classroom_manager.Assignment("Assignment 1", 100)
        assignment1.grade = None
        assignment2 = classroom_manager.Assignment("Quiz 1", 50)
        assignment2.grade = 50
        student.assignments = [assignment1, assignment2]

        self.assertEqual(student.get_average(), 50)
        assignment1.grade = 95
        self.assertEqual(student.get_average(), 72.5)
コード例 #4
0
    def set_up(self):
        # Set up test student values
        self.id = 4123
        self.first_name = "Adam"
        self.last_name = "Wright"
        self.assignments = []

        # Create a test student and test assignment
        self.test_student = classroom_manager.Student(4123, "Adam", "Wright")
        self.test_assignment = classroom_manager.Assignment("Assignment1", 100)
        self.test_assignment2 = classroom_manager.Assignment("Assignment2", 100)
コード例 #5
0
    def test_get_average(self):
        self.set_up()
        test_assignment3 = classroom_manager.Assignment("Assignment3", 50)
        test_assignment4 = classroom_manager.Assignment("Assignment4", 100)

        # Submit three test assignments and set grades for first two to 90 and 100
        self.test_student.submit_assignment(self.test_assignment)
        self.test_student.submit_assignment(test_assignment3)
        self.test_student.submit_assignment(test_assignment4)

        self.test_assignment.assign_grade(90)
        test_assignment3.assign_grade(48)

        # Test that test student's average is 95%
        self.assertEqual(self.test_student.get_average(), .92)
コード例 #6
0
    def test_assign_grade(self):
        self.set_up()

        # Create a test assignment with a proper grade
        self.test_assignment.assign_grade(98)
        self.assertEqual(self.test_assignment.grade, 98)

        # Create a test assignment with an out of range grade
        test_assignment2 = classroom_manager.Assignment("Assignment5", 100)
        test_assignment2.assign_grade(101)
        self.assertEqual(test_assignment2.grade, -1)

        # Create a test assignment with a full grade
        test_assignment2 = classroom_manager.Assignment("Assignment5", 100)
        test_assignment2.assign_grade(100)
        self.assertEqual(test_assignment2.grade, 100)
コード例 #7
0
    def set_up(self):
        self.name = "Assignment4"
        self.max_score = 100
        self.grade = -1

        # Create a test assignment instance
        self.test_assignment = classroom_manager.Assignment("Assignment4", 100)
コード例 #8
0
    def test_assign_grade(self):
        assignment = classroom_manager.Assignment('Quiz 1', 100)
        self.assertEqual(assignment.max_score, 100)

        assignment.assign_grade(100)
        self.assertEqual(assignment.grade, 100)
        assignment.assign_grade(101)
        self.assertEqual(assignment.grade, None)
コード例 #9
0
    def test_init(self):
        self.set_up()
        local_assignment = classroom_manager.Assignment("Assignment4", 100)

        # Test that the local assignment and the setup up assignment have the same props set
        self.assertEqual(local_assignment.name, self.test_assignment.name)
        self.assertEqual(local_assignment.max_score, self.test_assignment.max_score)
        self.assertEqual(local_assignment.grade, self.test_assignment.grade)
コード例 #10
0
    def test_prop_construct(self):
        name = "Quiz 1"
        max_score = 100
        grade = None

        # Constructor call
        assignment = classroom_manager.Assignment(name, max_score)

        self.assertEqual(name, assignment.name)
        self.assertEqual(max_score, assignment.max_score)
        self.assertEqual(grade, assignment.grade)
コード例 #11
0
 def test_get_assignments(self):
     assignment1 = classroom_manager.Assignment("Assignment 1", 100)
     assignment2 = classroom_manager.Assignment("Quiz 1", 50)
     student = classroom_manager.Student(1234, "Hannah", "Pittman")
     student.assignments = [assignment1, assignment2]
     self.assertEqual(student.get_assignments(), student.assignments)