コード例 #1
0
ファイル: main.py プロジェクト: JohnSdev/Inl-2-OOP
 def test_profit_02_sumOfPay(self):
     Nackadmein = School("Nackademin")
     staff1 = Staff("Mark", "Tomteboda 1", "Nackademin", 50)
     staff2 = Staff("Pike", "Tomteboda 3", "Nackademin", 50)
     Nackadmein.addStaff(staff1)
     Nackadmein.addStaff(staff2)
     self.assertEqual(Nackadmein.sumOfPay(), 100)
コード例 #2
0
    def order_question(self):
        #반복↓

        while True:
            #show menu
            # self.menu()

            print("1.학교에서\
                2.회사에서\
                3.공공장소에서\
                4.일상생활에서 ")

            User_S = input("알고싶은 문장의 번호를 선택하세요")

            if User_S == "":  #사용자가 엔터를 치면 끝난다.
                break
            elif User_S == '1':  #1을 누르면 school.py를 불러와서 실행
                s = School()
                s.run(User_S)
            elif User_S == '2':  #2을 누르면 school.py를 불러와서 실행
                o = Office()
                o.run(User_S)
            elif User_S == '3':  #3을 누르면 school.py를 불러와서 실행
                p = Public()
                p.run(User_S)
            elif User_S == '4':  #4을 누르면 school.py를 불러와서 실행
                l = Life()
                l.run(User_S)
コード例 #3
0
def dashboard_add_school():
    if 'school_name' in request.form:
        school_name = request.form['school_name']
        if not school_name == "":
            page = School(dsn=app.config['dsn'])
            return page.insert_school(school_name)
        else:
            return "bos"
    else:
        return render_template('dashboard_add_school.html')
コード例 #4
0
ファイル: test_school.py プロジェクト: REakin/lab_7
    def test_get_num_students_in_program(self):
        """ 060A - Valid Get Number of Student in Program """

        test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT")
        test_student_1.add_course("ACIT2515")

        test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CSD")
        test_student_2.add_course("COMP1510")

        test_student_3 = Student("Sally", "Jones", "A0100000002", "CSD")
        test_student_3.add_course("COMP1510")

        test_student_4 = Student("Julie", "Wong", "A0100000003", "CSD")
        test_student_4.add_course("COMP1510")

        test_school = School("Computing and Academic Studies")
        test_school.add_student(test_student_1)
        test_school.add_student(test_student_2)
        test_school.add_student(test_student_3)
        test_school.add_student(test_student_4)

        self.assertEqual(test_school.get_num_students_in_program("CIT"), 1,
                         "Must be only 1 CIT student")
        self.assertEqual(test_school.get_num_students_in_program("CSD"), 3,
                         "Must be 3 CSD students")
        self.assertEqual(test_school.get_num_students_in_program("SSD"), 0,
                         "Must be no SSD students")
コード例 #5
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_get_num_courses_in_program(self):
        """ 060A - Valid Get Number of Courses in Program """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A01000056")

        test_course_2 = Course("COMP1409", "123444", "CSD")
        test_course_2.add_student("A01000056")

        test_course_3 = Course("COMP1510", "123555", "CSD")
        test_course_3.add_student("A01000045")

        test_course_4 = Course("COMP2530", "123667", "CSD")
        test_course_4.add_student("A01000034")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)
        test_school.add_course(test_course_3)
        test_school.add_course(test_course_4)

        self.assertEqual(test_school.get_num_courses_in_program("CIT"), 1,
                         "Must be only 1 CIT course")
        self.assertEqual(test_school.get_num_courses_in_program("CSD"), 3,
                         "Must be 3 CSD courses")
        self.assertEqual(test_school.get_num_courses_in_program("SSD"), 0,
                         "Must be no SSD courses")
コード例 #6
0
class SchoolTest(unittest.TestCase):
    def setUp(self):
        self.school = School("Haleakala Hippy School")

    # def test_an_empty_school(self):
    #     self.assertEqual({}, self.school.db)

    # def test_add_student(self):
    #     self.school.add("Aimee", 2)
    #     self.assertEqual({2: {"Aimee"}}, self.school.db)

    # def test_add_more_students_in_same_class(self):
    #     self.school.add("James", 2)
    #     self.school.add("Blair", 2)
    #     self.school.add("Paul", 2)
    #     self.assertEqual({2: {"James", "Blair", "Paul"}}, self.school.db)

    # def test_add_students_to_different_grades(self):
    #     self.school.add("Chelsea", 3)
    #     self.school.add("Logan", 7)
    #     self.assertEqual({3: {"Chelsea"}, 7: {"Logan"}}, self.school.db)

    # def test_get_students_in_a_grade(self):
    #     self.school.add("Franklin", 5)
    #     self.school.add("Bradley", 5)
    #     self.school.add("Jeff", 1)
    #     self.assertEqual({"Franklin", "Bradley"}, self.school.grade(5))

    # def test_get_students_in_a_non_existant_grade(self):
    #     self.assertEqual(set(), self.school.grade(1))

    def test_sort_school(self):
        students = [
            (3, ("Kyle",)),
            (4, ("Christopher", "Jennifer",)),
            (6, ("Kareem",))
        ]

        for grade, students_in_grade in students:
            for student in students_in_grade:
                self.school.add(student, grade)

        result = self.school.sort()

        # Attempts to catch false positives
        self.assertTrue(isinstance(result, Sequence) or
                        isinstance(result, GeneratorType) or
                        callable(getattr(result, '__reversed__', False)))

        result_list = list(result.items() if hasattr(result, "items")
                           else result)

        self.assertEqual(result_list, students)
コード例 #7
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_get_non_existent_course(self):
        """ 050C - Invalid Get Course Non-Existent """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertIsNone(test_school.get_course("ACIT1234"), "No course should exists for ACIT1234")
コード例 #8
0
ファイル: test_school.py プロジェクト: REakin/lab_7
    def test_get_non_existent_student(self):
        """ 050C - Invalid Get Student Non-Existent """

        test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT")
        test_student_1.add_course("ACIT2515")

        test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT")
        test_student_2.add_course("ACIT2515")
        test_student_2.add_course("COMP1409")

        test_school = School("Computing and Academic Studies")
        test_school.add_student(test_student_1)
        test_school.add_student(test_student_2)

        self.assertIsNone(test_school.get_student("AXXXYYYZZZ"),
                          "No student should exists for AXXXYYYZZZ")
コード例 #9
0
ファイル: controller.py プロジェクト: monzag/school
def main_menu():
    school = School.create_from_csv('school.csv')

    user_choice = None
    while user_choice != 0:
        view.print_main_menu()
        user_choice = view.get_user_input()

        if user_choice == 1:
            view.get_list(school.get_all_teachers())

        elif user_choice == 2:
            print(school.get_best_class())

        elif user_choice == 3:
            choose_class(school)

        elif user_choice == 4:
            new_class = add_class(school)
            class_controller.class_menu(new_class)

        elif user_choice == 5:
            school.save_to_file()

    view.print_exit_message()
コード例 #10
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_add_course_undefined(self):
        """ 020B - Invalid Add Course Parameters """

        test_school = School("Computing and Academic Studies")

        invalid_course = None
        self.assertRaisesRegex(ValueError, "Course must be defined.", test_school.add_course, invalid_course)
コード例 #11
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_course_exists(self):
        """ 030A - Valid Course Exists """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertTrue(test_school.course_exists("ACIT2515"), "Course ACIT2515 must exist")
        self.assertTrue(test_school.course_exists("COMP1510"), "Course COMP1510 must exist")
コード例 #12
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_course_exists_not_existent_course(self):
        """ 030C - Valid Course Does Not Exist """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertFalse(test_school.course_exists("ACIT1234"), "Course ACIT1234 must NOT exist")
        self.assertFalse(test_school.course_exists("COMP4321"), "Course4321 must NOT exist")
コード例 #13
0
ファイル: user.py プロジェクト: nomunomu0504/procon26
    def create(cls, firstname, lastname, school, password_raw):
        """
		アカウント作成
		@param str firstname 名前
		@param str lastname  苗字
		@param str school 所属学校名
		@param str password_raw パスワード
		@return (bool, User|None) 成功か, ユーザ
		"""

        if not (firstname and lastname and school and password_raw):
            print(u"入力し忘れあるんじゃない?".encode("utf-8"))
            return False, None

        # Get the school'key. If it did not exist, quit this function.
        school_key = School.query(School.name == school).get(keys_only=True)
        if not school_key:
            return False, None

        # Create a user. returun this user.
        user = cls(firstname=firstname,
                   lastname=lastname,
                   school_key=school_key,
                   password_raw=security.generate_password_hash(password_raw,
                                                                length=20))
        user.put()
        return True, user
コード例 #14
0
def make_school(lb_student, ub_student, lb_classes, ub_classes):
    school = School(make_random_school_name())
    for _ in range(random.randint(lb_classes, ub_classes)):
        class_list = Class_List(make_random_name(), [])
        for __ in range(random.randint(lb_student, ub_student)):
            class_list.add_student(make_random_student())
        school.school_classes.append(class_list)
    return school
コード例 #15
0
ファイル: test_school.py プロジェクト: REakin/lab_7
    def test_add_student_undefined(self):
        """ 020B - Invalid Add Student Parameters """

        test_school = School("Computing and Academic Studies")

        invalid_student = None
        self.assertRaisesRegex(ValueError, "Student must be defined.",
                               test_school.add_student, invalid_student)
コード例 #16
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_get_school_details(self):
        """ 050A - Valid Get Course """
        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("BCIT")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)
        
        retreived_school = test_school.get_school_details()
        self.assertEqual(retreived_school["school_name"], "BCIT", "School must be named BCIT")
        self.assertEqual(retreived_school["num_courses"], 2, "School must have two programs")
        self.assertEqual(sorted(retreived_school["programs"]), sorted(["CIT", "CST"]), "School must have CST as the program")
コード例 #17
0
ファイル: main.py プロジェクト: JohnSdev/Inl-2-OOP
 def test_profit_01_sumOfFee(self):
     Nackadmein = School("Nackademin")
     studentx = Student("john", "gatan 12", "iot", 17, 5000)
     studenty = Student("peter", "gatan 2", "iot", 17, 5000)
     Iot = Program("IoT")
     Iot.addStudent(studentx)
     Iot.addStudent(studenty)
     self.assertEqual(Iot.sumOfFee(), 10000)
コード例 #18
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_get_course(self):
        """ 050A - Valid Get Course """
        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        retrieved_course = test_school.get_course("ACIT2515")
        self.assertEqual(retrieved_course.get_course_id(), "ACIT2515", "Course must have course ID ACIT2515")
        self.assertEqual(retrieved_course.get_crn(), "123456", "Course must have CRN 123456")
        self.assertEqual(retrieved_course.get_program(), "CIT", "Course must be in CIT program")
コード例 #19
0
ファイル: test_school.py プロジェクト: REakin/lab_7
    def test_get_student(self):
        """ 050A - Valid Get Student """
        test_student_1 = Student("Bill", "Smith", "A0100000000", "CIT")
        test_student_1.add_course("ACIT2515")

        test_student_2 = Student("Ken", "Rodgers", "A0100000001", "CIT")
        test_student_2.add_course("ACIT2515")
        test_student_2.add_course("COMP1409")

        test_school = School("Computing and Academic Studies")
        test_school.add_student(test_student_1)
        test_school.add_student(test_student_2)

        retrieved_student = test_school.get_student("A0100000001")
        self.assertEqual(retrieved_student.get_student_number(), "A0100000001",
                         "Student must have student number A0100000001")
        self.assertEqual(retrieved_student.get_program(), "CIT",
                         "Student must be in CIT program")
コード例 #20
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_add_course_already_exists(self):
        """ 020C - Course Already Exists """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_school = School("Computing and Academic Studies")
        self.assertEqual(test_school.get_num_courses(), 0, "School must have no courses")

        test_school.add_course(test_course_1)
        self.assertEqual(test_school.get_num_courses(), 1, "School must have 1 course")

        # Add the same course again
        test_school.add_course(test_course_1)
        self.assertEqual(test_school.get_num_courses(), 1, "School must still have only 1 course")
コード例 #21
0
ファイル: main.py プロジェクト: buitrungtbc4/hetrogiup
def signup():
    name = request.form['name']
    username = request.form['username'].strip()
    password = request.form['password'].strip()
    school = School(None, name, username, password)
    if insert_school(school):
        session['logged_in'] = True
        session['username'] = username
        session['name'] = name
    return redirect('/home')
コード例 #22
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_course_exists_invalid_course_id(self):
        """ 030B - Invalid Course ID Exists Parameters """

        test_school = School("Computing and Academic Studies")

        course_id_undef = None
        self.assertRaisesRegex(ValueError, "Course ID cannot be undefined.", test_school.course_exists, course_id_undef)

        course_id_empty = ""
        self.assertRaisesRegex(ValueError, "Course ID cannot be empty.", test_school.course_exists, course_id_empty)
コード例 #23
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_remove_course_invalid_course_id(self):
        """ 040B - Invalid Remove Course Parameters """

        test_school = School("Computing and Academic Studies")

        course_id_undef = None
        self.assertRaisesRegex(ValueError, "Course ID cannot be undefined.", test_school.remove_course, course_id_undef)

        course_id_empty = ""
        self.assertRaisesRegex(ValueError, "Course ID cannot be empty.", test_school.remove_course, course_id_empty)
コード例 #24
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_get_num_courses_in_program_invalid_program_name(self):
        """ 060B - Invalid Get Num Course in Program Parameters """

        test_school = School("Computing and Academic Studies")

        program_name_undef = None
        self.assertRaisesRegex(ValueError, "Program Name cannot be undefined.", test_school.get_num_courses_in_program, program_name_undef)

        program_name_empty = ""
        self.assertRaisesRegex(ValueError, "Program Name cannot be empty.", test_school.get_num_courses_in_program, program_name_empty)
コード例 #25
0
ファイル: account.py プロジェクト: calebgch/python_learning
 def add_school(self):
     school_name = input("输入学校名:")
     school_addr = input("输入学校地址:")
     new_school = School(school_name, school_addr)
     school_list = get_school_list()
     for school in school_list:
         if school.name == new_school.name:
             print("新增学校失败,学校已存在")
             return
     school_list.append(new_school)
     save()
コード例 #26
0
def run():
    school = School.create_schoow_witch_students("nr. 3")
    print(
        f"W szkole może być maksymalnie {school.MAX_STUDENTS_NUMBER} uczniów\n"
    )
    # new_school = School.create_schoow_witch_students("Nowa szkoła")
    # print(new_school)
    # print(f"W nowej szkole może być maksymalnie {new_school.MAX_STUDENTS_NUMBER} uczniów")
    marcin = Student("Marcin", "Borchowiec")
    school.assign_student(marcin)
    print(school)
コード例 #27
0
 def award_degree():
     # To be able to reload
     if request.method == 'GET':
         return render_template('index.html', js_folder=url_for('static', filename='js'),
                                img_folder=url_for('static', filename='img'),
                                css_folder=url_for('static', filename='css'),
                                school=1)
     try:
         school = School(session['school_seed'])
         name = request.form['name'].lower()
         response = school.award_degree(request.form['address'], name, request.form['birthdate'], request.form['year'])
         return render_template('index.html', js_folder=url_for('static', filename='js'),
                                img_folder=url_for('static', filename='img'),
                                css_folder=url_for('static', filename='css'),
                                school=1, txhash=response['hash'])
     except Exception as e:
         return render_template('index.html', js_folder=url_for('static', filename='js'),
                                img_folder=url_for('static', filename='img'),
                                css_folder=url_for('static', filename='css'),
                                school=1, awarderror=e)
コード例 #28
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_add_course(self):
        """ 020A - Valid Add Course """
        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        self.assertEqual(test_school.get_num_courses(), 0, "School must have no courses")

        test_school.add_course(test_course_1)
        self.assertEqual(test_school.get_num_courses(), 1, "School must have 1 course")

        test_school.add_course(test_course_2)
        self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses")
コード例 #29
0
    def __read_instance__(self, path_kinderen, path_schools):

        with open(path_schools, "r") as file:
            schools_content = json.load(file)

        with open(path_kinderen, 'r') as file:
            kinderen_content = json.load(file)

        self.school_ids_uniek = list(schools_content.keys())
        self.student_ids = list(kinderen_content.keys())

        # initialize schools
        for school_id, school_info in schools_content.items():

            preferences = school_info.get("applicaties")
            preferences = [(kind_id, preferences.get(kind_id).get('toeval'))
                           for kind_id in preferences.keys()]
            preferences.sort(key=lambda x: x[1])
            preferences = [i[0] for i in preferences
                           ]  # drop toeval, enkel rangorde in lijst telt nu

            school = School(unique_id=school_info.get("school_id_uniek"),
                            school_id=school_info.get("school_id"),
                            ind_capacity=school_info.get('INDCapaciteit'),
                            n_ind_capacity=school_info.get('nINDCapaciteit'),
                            preferences=preferences)
            self.schools.update({school_id: school})

        # initialize alle kinderen
        for kind_id, kind_info in kinderen_content.items():

            preferences = kind_info.get('applicaties')
            preferences = [(school_id,
                            preferences.get(school_id).get('voorkeur'))
                           for school_id in preferences.keys()]
            preferences.sort(key=lambda x: x[1])
            preferences = [i[0] for i in preferences]

            applicaties = [
                Application(periode=item.get("periode"),
                            student_id=kind_id,
                            school_id=key,
                            voorkeur_student=item.get("voorkeur"),
                            toeval=item.get('toeval'))
                for key, item in kind_info.get('applicaties').items()
            ]

            kind = Student(id=kind_id,
                           school_preferences=preferences,
                           indicator_status=kind_info.get("indicator_status"),
                           applicaties=applicaties)

            self.kinderen.update({kind_id: kind})
コード例 #30
0
ファイル: test_school.py プロジェクト: lupomancer/Python
    def test_remove_course(self):
        """ 040A - Valid Remove Course """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses")
        self.assertTrue(test_school.course_exists("ACIT2515"))
        self.assertTrue(test_school.course_exists("COMP1510"))

        test_school.remove_course("ACIT2515")
        self.assertEqual(test_school.get_num_courses(), 1, "School must have 1 course")
        self.assertFalse(test_school.course_exists("ACIT2515"))
コード例 #31
0
class SchoolTest(unittest.TestCase):
    def setUp(self):
        self.school = School("Haleakala Hippy School")

    def test_an_empty_school(self):
        self.assertEqual({}, self.school.db)

    def test_add_student(self):
        self.school.add("Aimee", 2)
        self.assertEqual({2: {"Aimee"}}, self.school.db)

    def test_add_more_students_in_same_class(self):
        self.school.add("James", 2)
        self.school.add("Blair", 2)
        self.school.add("Paul", 2)
        self.assertEqual({2: {"James", "Blair", "Paul"}}, self.school.db)

    def test_add_students_to_different_grades(self):
        self.school.add("Chelsea", 3)
        self.school.add("Logan", 7)
        self.assertEqual({3: {"Chelsea"}, 7: {"Logan"}}, self.school.db)

    def test_get_students_in_a_grade(self):
        self.school.add("Franklin", 5)
        self.school.add("Bradley", 5)
        self.school.add("Jeff", 1)
        self.assertEqual({"Franklin", "Bradley"}, self.school.grade(5))

    def test_get_students_in_a_non_existant_grade(self):
        self.assertEqual(set(), self.school.grade(1))

    def test_sort_school(self):
        students = [
            (3, ("Kyle",)),
            (4, ("Christopher", "Jennifer",)),
            (6, ("Kareem",))
        ]

        for grade, students_in_grade in students:
            for student in students_in_grade:
                self.school.add(student, grade)

        result = self.school.sort()

        # Attempts to catch false positives
        self.assertTrue(isinstance(result, Sequence) or
                        isinstance(result, GeneratorType) or
                        callable(getattr(result, '__reversed__', False)))

        result_list = list(result.items() if hasattr(result, "items")
                           else result)

        self.assertEqual(result_list, students)
コード例 #32
0
class SchoolTest(unittest.TestCase):
    def setUp(self):
        self.school = School("Haleakala Hippy School")

    def test_an_empty_school(self):
        self.assertEqual({}, self.school.db)

    def test_add_student(self):
        self.school.add("Aimee", 2)
        self.assertEqual({2: {"Aimee"}}, self.school.db)

    def test_add_more_students_in_same_class(self):
        self.school.add("James", 2)
        self.school.add("Blair", 2)
        self.school.add("Paul", 2)
        self.assertEqual({2: {"James", "Blair", "Paul"}}, self.school.db)

    def test_add_students_to_different_grades(self):
        self.school.add("Chelsea", 3)
        self.school.add("Logan", 7)
        self.assertEqual({3: {"Chelsea"}, 7: {"Logan"}}, self.school.db)

    def test_get_students_in_a_grade(self):
        self.school.add("Franklin", 5)
        self.school.add("Bradley", 5)
        self.school.add("Jeff", 1)
        self.assertEqual({"Franklin", "Bradley"}, self.school.grade(5))

    def test_get_students_in_a_non_existant_grade(self):
        self.assertEqual(set(), self.school.grade(1))

    def test_sort_school(self):
        self.school.add("Jennifer", 4)
        self.school.add("Kareem", 6)
        self.school.add("Christopher", 4)
        self.school.add("Kyle", 3)
        sorted_students = {
            3: ("Kyle",),
            4: ("Christopher", "Jennifer",),
            6: ("Kareem",)
        }
        self.assertEqual(sorted_students, self.school.sort())
コード例 #33
0
 def setUp(self):
     # assertCountEqual is py3, py2 only knowns assetItemsEqual
     if not hasattr(self, 'assertCountEqual'):
         self.assertCountEqual = self.assertItemsEqual
     self.school = School("Haleakala Hippy School")
コード例 #34
0
 def setUp(self): # runs every time so we get a new school
     self.school = School("Haleakala Hippy School")
コード例 #35
0
 def setUp(self):
     self.school = School("Haleakala Hippy School")
 def create_school(cls):
     for s in cls.school_list:
         school = School.create(name=s['name'], cid=s['cid'])
コード例 #37
0
class SchoolTest(unittest.TestCase):
    def setUp(self):
        self.school = School("Haleakala Hippy School")

    def test_an_empty_school(self):
        self.assertEqual({}, self.school.db)

    def test_add_student(self):
        self.school.add("Aimee", 2)
        self.assertEqual({2: {"Aimee"}}, self.school.db)

    def test_add_more_students_in_same_class(self):
        self.school.add("James", 2)
        self.school.add("Blair", 2)
        self.school.add("Paul", 2)
        self.assertEqual({2: {"James", "Blair", "Paul"}}, self.school.db)

    def test_add_students_to_different_grades(self):
        self.school.add("Chelsea", 3)
        self.school.add("Logan", 7)
        self.assertEqual({3: {"Chelsea"}, 7: {"Logan"}}, self.school.db)

    def test_get_students_in_a_grade(self):
        self.school.add("Franklin", 5)
        self.school.add("Bradley", 5)
        self.school.add("Jeff", 1)
        self.assertEqual({"Franklin", "Bradley"}, self.school.grade(5))

    def test_get_students_in_a_non_existant_grade(self):
        self.assertEqual(None, self.school.grade(1))

    def test_sort_school(self):
        self.school.add("Jennifer", 4)
        self.school.add("Kareem", 6)
        self.school.add("Christopher", 4)
        self.school.add("Kyle", 3)
        sorted_students = {
            3: ("Kyle",),										#For some reason this test includes an extra comma at the end of each dictionary value. The values are also now in parentheses, not sets. 
            4: ("Christopher", "Jennifer",),
            6: ("Kareem",)
        }
        self.assertEqual(sorted_students, self.school.sort())