예제 #1
0
def test_with_two_classes_starts_the_same_time():
    temp = Student(id=1)
    first_classwork = Classwork('Test', random_day=1, random_hour=18, id=3)
    second_classwork = Classwork('Test', random_day=1, random_hour=18, id=4)
    classworks = [first_classwork, second_classwork]
    temp.timetable = classworks

    assert temp.calculate_student_fitness() == 90
 def test_add_course(self):
     st = Student(1234, "ABC", "CS")
     st.add_course("CS120", "A")
     self.assertEqual(
         st.student_details, {
             'student_id': 1234,
             'student_name': 'ABC',
             'student_major': 'CS',
             'student_courses_taken': {
                 'CS120': 'A'
             }
         })
예제 #3
0
class TestFizz2AndBuzz4(unittest.TestCase):
    def setUp(self):
        self.student = Student(2, 4)

    def test4ExpectFizzBuzz(self):
        gameResult = self.student.game(4)
        expectResult = "FizzBuzz"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult\

    def test6ExpectFizz(self):
        gameResult = self.student.game(4)
        expectResult = "FizzBuzz"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult
예제 #4
0
 def get_or_create_student(self, name):
     if name in self.students:
         return self.students[name]
     else:
         student = Student(name)
         self.students[name] = student
         return student
    def _print_student_data_in_table(self):
        def set_diff(s1, s2):
            if s1.isdisjoint(s2):
                return s1
            else:
                return None

        x = PrettyTable()

        x.field_names = Student.student_header()

        for val in self._student_list:
            temp = sorted(
                list(self._student_list[val].
                     student_details["student_courses_taken"].keys()))
            x.add_row([
                self._student_list[val].student_details["student_id"],
                self._student_list[val].student_details["student_name"], temp,
                set(self._major[self._student_list[val].student_details[
                    "student_major"]].get_required_course()) - set(temp),
                set_diff(
                    set(self._major[self._student_list[val].student_details[
                        "student_major"]].get_elective_course()), set(temp))
            ])
        return x
 def populate_student_data(self, student_data):
     for val in student_data:
         if val[2] not in self._major:
             raise ValueError(
                 f"You have wrong major in the file supplied major = {val[2]}"
             )
         st = Student(val[0], val[1], val[2])
         self.add_student(st)
예제 #7
0
class TestFizz3AndBuzz5(unittest.TestCase):
    def setUp(self):
        self.student = Student(3, 5)

    def test0Expectnull(self):
        gameResult = self.student.game(0)
        expectResult = ""
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult

    def test1Expect1(self):
        gameResult = self.student.game(1)
        expectResult = "1"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult

    def test3ExpectFizz(self):
        gameResult = self.student.game(3)
        expectResult = "Fizz"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult

    def test13ExpectFizz(self):
        gameResult = self.student.game(13)
        expectResult = "Fizz"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult

    def test15ExpectFizzBuzz(self):
        gameResult = self.student.game(15)
        expectResult = "FizzBuzz"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult

    def test5ExpectBuzz(self):
        gameResult = self.student.game(5)
        expectResult = "Buzz"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult

    def test52ExpectBuzz(self):
        gameResult = self.student.game(52)
        expectResult = "Buzz"
        assert gameResult == expectResult, "expect: " + \
            expectResult + " , But get: " + gameResult

    def testRange1To100ExpectInList(self):
        for i in range(100):
            i += 1
            gameResult = self.student.game(i)
            assert gameResult in [str(i), "Fizz", "Buzz", "FizzBuzz"],\
                "gameResult Not in expect List, But get: " + gameResult
예제 #8
0
def test_calculate_student_fitness_with_multiple_overlapping(multiple_classworks_with_overlapping):
    temp = Student(id=1)
    temp.timetable = multiple_classworks_with_overlapping

    assert temp.calculate_student_fitness() == 300
예제 #9
0
def test_calculate_day_overlapping_with_overlapping(classworks_with_overlapping):
    overlapping_day_classwork = classworks_with_overlapping

    temp = Student(id=1)

    assert temp.calculate_day_overlapping(overlapping_day_classwork) == 60
 def setUp(self):
     self.student = Student("Max", "Toronii")
     self.professor = Professor("John", "Smith")
     self.dean_office_employee = DeanOfficeEmployee("Mike", "Esperanto")
class GradesSystemTest(unittest.TestCase):
    def setUp(self):
        self.student = Student("Max", "Toronii")
        self.professor = Professor("John", "Smith")
        self.dean_office_employee = DeanOfficeEmployee("Mike", "Esperanto")

    def test_student_doesnt_have_grade(self):
        self.assertEqual(len(self.student.grades), 0,
                         "Student should NOT have a grade initially")

    def test_students_grade_is_not_validate(self, grade=3):
        self.professor.put_grade("SDM", 20192, grade, self.student)
        self.assertFalse(
            self.student.grades[len(self.student.grades) - 1]['valid'],
            "Student should NOT have a validated grade")

    def test_grade_has_value_after_professor_put_grade(self, grade=5):
        self.professor.put_grade("SDM", 20192, grade, self.student)
        self.assertEqual(len(self.student.grades), 1,
                         "Student should have one grade")
        self.assertEqual(
            self.student.grades[len(self.student.grades) - 1]['value'], grade,
            "Student should have the grade with value " + str(grade))
        self.assertFalse(self.student.is_grade_validated(index=0),
                         "Student grade should NOT have validated grade")

    def test_grade_is_validated_after_validation(self, grade=5):
        self.professor.put_grade("SDM", 20192, grade, self.student)
        self.dean_office_employee.validate_grade(
            self.student, index=len(self.student.grades) - 1)
        self.assertEqual(len(self.student.grades), 1,
                         "Student should have one grade")
        self.assertEqual(
            self.student.grades[len(self.student.grades) - 1]['value'], grade,
            "Student should have the grade with value " + str(grade))
        self.assertTrue(
            self.student.is_grade_validated(index=len(self.student.grades) -
                                            1),
            "Student should have validated grade")

    def test_student_has_multiple_grades(self, number_grades=3, grade=4):
        for i in range(number_grades):
            self.professor.put_grade("SDM", 20192, grade, self.student)
        self.assertEqual(
            len(self.student.grades), number_grades,
            "Student should have " + str(number_grades) + " grades")
        for i in range(number_grades):
            self.assertFalse(self.student.is_grade_validated(index=i),
                             "Student grade should NOT have validated grade")

    def test_dean_office_validate_one_of_many_grades(self,
                                                     number_grades=3,
                                                     grade=4,
                                                     index_valid_grade=1):
        self.assertTrue(
            index_valid_grade >= 0 and index_valid_grade < number_grades,
            "Wrong test parameters")

        for i in range(number_grades):
            self.professor.put_grade("SDM", 20192, grade, self.student)
        self.assertEqual(
            len(self.student.grades), number_grades,
            "Student should have " + str(number_grades) + " grades")
        self.dean_office_employee.validate_grade(self.student,
                                                 index=index_valid_grade)
        for i in range(number_grades):
            if (i == index_valid_grade):
                self.assertTrue(
                    self.student.is_grade_validated(index=index_valid_grade),
                    "Student should have validated grade")
            else:
                self.assertFalse(
                    self.student.is_grade_validated(index=i),
                    "Student grade should NOT have validated grade")

    def test_dean_office_validate_all_grades(self, number_grades=3, grade=4):
        for i in range(number_grades):
            self.professor.put_grade("SDM", 20192, grade, self.student)
        for i in range(number_grades):
            self.dean_office_employee.validate_grade(self.student, index=i)
        for i in range(number_grades):
            self.assertTrue(self.student.is_grade_validated(index=i),
                            "Student should have validated grade")

    def test_dean_office_fail_validate_grade(self, grade=1):
        self.assertTrue(grade > 5 or grade < 2, "Wrong test parameters")

        self.professor.put_grade("SDM", 20192, grade, self.student)
        self.dean_office_employee.validate_grade(
            self.student, index=len(self.student.grades) - 1)
        self.assertFalse(
            self.student.is_grade_validated(index=len(self.student.grades) -
                                            1),
            "Student grade should NOT have validated grade")
예제 #12
0
 def setUp(self):
     self.student = Student(3, 5)
예제 #13
0
def FizzAndBuzz(FizzNum, BuzzNum):
    student = Student(FizzNum, BuzzNum)
    for i in range(100):
        print student.game(i)
예제 #14
0
import gettext

from src.Student import Student
from src.Subject import Subject
from src.Person import Person
from src.Teacher import Teacher

if __name__ == '__main__':

    gettext.install(domain='main', localedir='locales')

    p1 = Person('pol', 'torres', 'alfonso', 'calleFalsa', '482594591')

    subjects = [
        Subject('maths', '1', '9'),
        Subject('biology', '11', '9'),
        Subject('physics', '13', '9')
    ]

    s1 = Student('pol', 'torres', 'alfonso', 'calleFalsa', '482594591', '15',
                 '4', subjects)
    t1 = Teacher('pol', 'torres', 'alfonso', 'calleFalsa', '482594591', '999',
                 subjects)

    p1.print_person()
    t1.printTeacher()
    s1.print_student()
예제 #15
0
 def setUp(self):
     self.student = Student(2, 4)