Exemplo n.º 1
0
 def test_everyone_matched_is_stable(self):
     student_1 = Student(1, [self.p_1, self.p_2])
     student_2 = Student(2, [self.p_2, self.p_1])
     students = [student_1, student_2]
     matcher = Matcher(students)
     matcher.match()
     self.assertTrue(matcher.is_stable())
Exemplo n.º 2
0
 def test_some_matched_none_is_unstable(self):
     student_1 = Student(1, [self.p_1, self.p_2])
     student_2 = Student(2, [self.p_2, self.p_1])
     student_1.project = None
     students = [student_1, student_2]
     matcher = Matcher(students)
     self.assertFalse(matcher.is_stable())
Exemplo n.º 3
0
class TestStudent(unittest.TestCase):
    def setUp(self):
        self.student = Student("Ada", "E42")

    
    def test_student_has_name(self):
        self.assertEqual("Ada", self.student.name)

    
    def test_student_has_cohort(self):
        self.assertEqual("E42", self.student.cohort)

    
    def test_student_can_update_name(self):
        self.student.name = "Mike"
        self.assertEqual("Mike", self.student.name)

    
    def test_student_can_change_cohort(self):
        self.student.cohort = "G21"
        self.assertEqual("G21", self.student.cohort)

    
    def test_student_can_talk(self):
        self.assertEqual("I can talk!", self.student.talk())

    def test_student_has_favourite_language(self):
        self.assertEqual("I love python", self.student.say_favourite_language("python"))
Exemplo n.º 4
0
def login(identity_int):
    # 学生注册
    global obj
    if identity_int == 3:
        return Student()

    identity_dict = {
        1: "Teacher",
        2: "Student",
        4: "Manager",
    }
    id_num = input("Please input " + identity_dict[identity_int] + " id: ")
    password = input("Please input " + identity_dict[identity_int] +
                     " password: "******"Wrong user name or password!")
Exemplo n.º 5
0
 def test_student_with_highest_priority_is_prioritized(self):
     student_1 = Student(1, [self.p_1, self.p_2])
     student_2 = Student(2, [self.p_1, self.p_2])
     def priority(student, project):
         return 2 if student == student_1 else 1
     matcher = Matcher([student_1, student_2], priority)
     matcher.match()
     self.assertEqual(student_1.project, self.p_1)
     self.assertEqual(student_2.project, self.p_2)
Exemplo n.º 6
0
 def test_each_student_is_prioritized(self):
     student_1 = Student(1, [self.p_1, self.p_2, self.p_3])
     student_2 = Student(2, [self.p_2, self.p_1, self.p_3])
     student_3 = Student(3, [self.p_3, self.p_1, self.p_2])
     matcher = Matcher([student_1, student_2, student_3])
     matcher.match()
     self.assertEqual(student_1.project, self.p_1)
     self.assertEqual(student_2.project, self.p_2)
     self.assertEqual(student_3.project, self.p_3)
Exemplo n.º 7
0
 def __init__(self, dict):
     self.__room = Room(dict["room_num"], dict["clean_rating"],
                        dict["electrical_appliance"], dict["sex"])
     self.__inventory = Inventory(dict["inventory_name"], dict["name"],
                                  dict["surname"], dict["patronymic"],
                                  dict["amount"], dict["num_in_queue"])
     self.__student = Student(dict["name"], dict["surname"],
                              dict["patronymic"], dict["bd"], dict["email"],
                              dict["faculty"], dict["course"],
                              dict["room_num"], dict["phone_number"],
                              dict["sex"])
Exemplo n.º 8
0
class Test(unittest.TestCase):

    def setUp(self):
        self.stud = Student('Douglas', 'Detoni')

    def testSetInteraction(self):
        self.assertEqual(self.stud.set_interation('1357042332'), 1)
        self.assertEqual(self.stud.set_interation('1357024805'), 2)

        self.assertEqual(self.stud.set_interation('1388484672'), 1)
        self.assertEqual(self.stud.set_interation('1388509872'), 2)

        self.assertEqual(self.stud.set_interation('1341162672'), None)
        self.assertEqual(self.stud.set_interation('1392484272'), None)
 def test_priority_of_student_is_ratio_of_project_keywords_matched(self):
     project_kws = self.n_keywords(10)
     student_kws = self.n_keywords(2)
     student_kws += self.other_keywords(37)
     project = Project(1, keywords=project_kws)
     student = Student(1, [project], keywords=student_kws)
     self.assertEqual(keywords_priority_calculator(student, project), 0.2)
 def test_priority_of_student_is_one_if_all_keywords_match(self):
     kw_1 = 'kw_1'
     kw_2 = 'kw_2'
     kw_3 = 'kw_3'
     kws = [kw_1, kw_2, kw_3]
     project = Project(1, keywords=kws)
     student = Student(1, [project], keywords=kws)
     self.assertEqual(keywords_priority_calculator(student, project), 1)
Exemplo n.º 11
0
 def crent_student(self, stu_name, stu_age, stu_sex, cls_name):
     #创建学生对象
     student_obj = Student(stu_name, stu_age, stu_sex)
     self.sch_student[stu_name] = student_obj
     #建立学生和班级的对应关系
     class_obj = self.sch_classroom[cls_name]
     class_obj.class_student[stu_name] = student_obj
     #更新班级信息
     self.sch_classroom[cls_name] = class_obj
 def test_priority_of_student_is_zero_if_none_match(self):
     kw_1 = 'kw_1'
     kw_2 = 'kw_2'
     kw_3 = 'kw_3'
     kw_4 = 'kw_4'
     student_kws = [kw_1, kw_2]
     project_kws = [kw_3, kw_4]
     project = Project(1, keywords=project_kws)
     student = Student(1, [project], keywords=student_kws)
     self.assertEqual(keywords_priority_calculator(student, project), 0)
Exemplo n.º 13
0
 def create_student(self, student_name, student_age, student_sex):
     """
     创建学生对象的方法函数,并将学生关联学校
     :param student_name: 学生姓名
     :param student_age: 学生年龄
     :param student_sex: 学生性别
     :return:
     """ ""
     student_obj = Student(student_name, student_age,
                           student_sex)  # 实例化学生类得到学生对象
     self.school_student[student_name] = student_obj  # 学生关联学校
Exemplo n.º 14
0
 def create_student(self, name, gender, age, class_name):
     #1.创建学生对象,赋值变量
     student_obj = Student(name, gender, age)
     #2.根据学生名称为key,学生对象为value来建立对应关系
     self.sch_student[name] = student_obj
     #3.建立学生和班级的关联关系
     class_obj = self.sch_classroom[class_name]
     #4.存放学生对象,班级类的class_student存放学生对象
     class_obj.class_student[class_name] = student_obj
     #5.更新班级信息
     self.sch_classroom[class_name] = class_obj
Exemplo n.º 15
0
class TestStudent(unittest.TestCase):
    def setUp(self):
        self.student = Student("Ada", "E42", "Python", 35)

# @unittest.skip("delete this line to run the test")

    def test_student_has_name(self):
        self.assertEqual("Ada", self.student.name)

# @unittest.skip("delete this line to run the test")

    def test_student_has_cohort(self):
        self.assertEqual("E42", self.student.cohort)

# @unittest.skip("delete this line to run the test")

    def test_student_can_update_name(self):
        self.student.name = "Mike"
        self.assertEqual("Mike", self.student.name)

# @unittest.skip("delete this line to run the test")

    def test_student_can_change_cohort(self):
        self.student.cohort = "G21"
        self.assertEqual("G21", self.student.cohort)

# @unittest.skip("delete this line to run the test")

    def test_student_can_talk(self):
        self.assertEqual("I can talk!", self.student.talk())

# @unittest.skip("delete this line to run the test")

    def test_student_has_favourite_language(self):
        self.assertEqual("I love Python",
                         self.student.say_favourite_language())

    def test_get_commute_time(self):
        self.assertEqual("It takes me 35 minutes to get to CodeClan",
                         self.student.get_commute_time("Ada"))
Exemplo n.º 16
0
def main():
    all_files = os.listdir(config.import_conf.dir)
    files = []
    for file in all_files:
        if re.match(config.import_conf.regex_file, file):
            files.append(file)
    print(files, end='\n')

    for file in files:
        filename = config.import_conf.dir + file
        print('\n' + filename)
        doc_import = ImportFile(filename)

        group = config.user_conf.group
        domain = config.user_conf.domain
        password = config.user_conf.password
        ou = config.user_conf.ou

        names = doc_import.grouplist

        header_users = [[
            "First Name [Required]", "Last Name [Required]",
            "Email Address [Required]", "Password [Required]",
            "Org Unit Path [Required]", "Change Password at Next Sign-In"
        ]]
        print('creating users csv')
        with open("output/users_" + file + group + ".csv",
                  'w',
                  newline='',
                  encoding='utf-8') as csv_file:
            writer = csv.writer(csv_file, delimiter=',')
            for line in header_users:
                writer.writerow(line)
            for f_name in names:
                if f_name is not None:
                    if config.import_conf.split_FIO:
                        name = f_name.split(' ')
                    else:
                        name = f_name
                    stud = Student(name, domain, group, password, ou)
                    writer.writerow(stud.add_csv_users_line())

        header_groups = [[
            "Group Email [Required]", "Member Email", "Member Type",
            "Member Role"
        ]]
        print('creating group csv')
        with open("output/group_" + file + "_" + group + ".csv",
                  'w',
                  newline='',
                  encoding='utf-8') as csv_file:
            writer = csv.writer(csv_file, delimiter=',')
            for line in header_groups:
                writer.writerow(line)
            for f_name in names:
                if f_name is not None:
                    name = f_name.split(' ')
                    stud = Student(name, domain, group, password, ou)
                    writer.writerow(stud.add_csv_groups_line())
Exemplo n.º 17
0
    def create_student(self, stu_name, stu_gender, stu_age, classroom_name):
        # 创建学生对象
        student_obj = Student(stu_name, stu_gender, stu_age)
        self.sch_student[stu_name] = student_obj
        # print(stu_obj)
        # 建立学生和班级的关联关系
        # 获取班级对象
        classroom_obj = self.sch_classroom[classroom_name]
        print(classroom_obj)
        # classroom_obj.classroom_student 获取字典值,取自src.classroom类中的 classroom_student 属性
        # 班级对象 包含 classroom_student 对应字典,字典关系  班级名:学生对象
        classroom_obj.classroom_student[classroom_name] = student_obj

        # 更新班级信息
        self.sch_classroom[classroom_name] = classroom_obj
        for cls in classroom_obj.classroom_student:
            print(cls)
 def test_priority_of_student_is_his_grade_normalized(self):
     student = Student(1, ['a_project'], grade=7)
     self.assertEqual(grade_priority_calculator(student),
                      student.grade / 10)
Exemplo n.º 19
0
 def setUp(self):
     self.student = Student("Ada", "E42")
Exemplo n.º 20
0
def read_option():
    while True:
        system("cls")
        student = Student()
        course = Course()
        option = str(input(menu()))
        if option in ["1", "2", "3", "4", "5", "6", "7", "8", "9"]:

            system("cls")

            if (option == "1"):
                print("ALUNOS")
                print("-" * 20)
                StudentDAO().read()

                print("CURSOS")
                print("-" * 20)
                CourseDAO().read()

                print("DADOS DE CADASTRO")
                print("-" * 20)
                student.set_id_student(input("ID: "))
                student.set_name(input("Nome: "))
                student.set_email(input("Email: "))
                student.set_address(input("Endereço: "))
                student.set_city(input("Cidade: "))
                student.set_uf(input("UF: "))
                student.set_id_course(input("Curso_ID: "))
                StudentDAO().create(student)

            elif (option == "2"):
                StudentDAO().read()

            elif (option == "3"):
                print("ALUNOS")
                print("-" * 20)
                StudentDAO().read()

                print("CURSOS")
                print("-" * 20)
                CourseDAO().read()

                print(
                    "DIGITE O ID DO ALUNO QUE DESEJA ATUALIZAR, EM SEGUIDA ATUALIZE AS INFORMAÇÕES"
                )
                print("-" * 20)
                student.set_id_student(input("ID: "))
                student.set_name(input("Nome: "))
                student.set_email(input("Email: "))
                student.set_address(input("Endereço: "))
                student.set_city(input("Cidade: "))
                student.set_uf(input("UF: "))
                student.set_id_course(input("Curso_ID: "))
                StudentDAO().update(student)

            elif (option == "4"):
                print("ALUNOS")
                print("-" * 20)
                StudentDAO().read()

                print("DIGITE O ID DO ALUNO QUE DESEJA REMOVER")
                print("-" * 20)
                student.set_id_student(input("ID: "))
                StudentDAO().delete(student)

            elif (option == "5"):
                print("CURSOS")
                print("-" * 20)
                CourseDAO().read()

                print("DADOS DE CADASTRO")
                print("-" * 20)
                course.set_id_course(input("ID: "))
                course.set_description(input("Nome: "))
                course.set_price(input("Preço: "))
                course.set_period(input("Periodo: "))
                CourseDAO().create(course)

            elif (option == "6"):
                CourseDAO().read()

            elif (option == "7"):
                print("CURSOS")
                print("-" * 20)
                CourseDAO().read()

                print(
                    "DIGITE O ID DO CURSO QUE DESEJA ATUALIZAR, EM SEGUIDA ATUALIZE AS INFORMAÇÕES"
                )
                print("-" * 20)
                course.set_id_course(input("ID: "))
                course.set_description(input("Nome: "))
                course.set_price(input("Preço: "))
                course.set_period(input("Periodo: "))
                CourseDAO().update(course)

            elif (option == "8"):
                print("CURSOS")
                print("-" * 20)
                CourseDAO().read()

                print("DIGITE O ID DO CURSO QUE DESEJA REMOVER")
                print("-" * 20)
                course.set_id_course(input("ID: "))
                CourseDAO().delete(course)

            elif (option == "9"):
                break

            system("pause")
Exemplo n.º 21
0
 def create_sample_students(self, n):
     projects = [Project(i) for i in range(1, n + 1)]
     students = [Student(i, projects) for i in range(1, n + 1)]
     return students, projects
Exemplo n.º 22
0
    def create_student(self,sch_stu_name,sch_stu_age,sch_stu_sex,cls_name):
        sch_stu_obj = Student(sch_stu_name,sch_stu_age,sch_stu_sex)
        self.sch_student[sch_stu_name] = sch_stu_obj

        stu_cls_obj = self.sch_classroom[cls_name]
        self.sch_classroom[cls_name] = sch_stu_obj
Exemplo n.º 23
0
 def test_matches_one_student_and_one_project(self):
     student = Student(1, [self.p_1])
     matcher = Matcher([student])
     matcher.match()
     self.assertEqual(student.project, self.p_1)
Exemplo n.º 24
0
 def setUp(self):
     self.student = Student("Ada", "E42", "Python", 35)
Exemplo n.º 25
0
 def make_three_students(self):
     student_1 = Student(1, [self.p_1, self.p_2, self.p_3])
     student_2 = Student(2, [self.p_2, self.p_1, self.p_3])
     student_3 = Student(3, [self.p_3, self.p_1, self.p_2])
     return [student_1, student_2, student_3]
Exemplo n.º 26
0
 def test_student_is_unmatched(self):
     student = Student(1, [ProjectMock()])
     self.assertFalse(student.is_matched)
Exemplo n.º 27
0
 def test_student_is_matched_with_project(self):
     student = Student(1, [ProjectMock()])
     student.project = 1
     self.assertTrue(student.is_matched)
 def test_priority_should_be_one_if_departments_match(self):
     dept = 'dept'
     project = Project(1, department=dept)
     student = Student(1, [project], department=dept)
     self.assertEqual(department_priority_calculator(student, project), 1)
 def test_priority_should_be_zero_if_department_does_not_match(self):
     dept_1 = 'dept_1'
     dept_2 = 'dept_2'
     project = Project(1, department=dept_1)
     student = Student(1, [project], department=dept_2)
     self.assertEqual(department_priority_calculator(student, project), 0)
Exemplo n.º 30
0
 def test_pair_student_project(self):
     student = Student(1, [self.p_1])
     matcher = Matcher([student])
     matcher.pair(student, self.p_1)
     self.assertEqual(student.project, self.p_1)
Exemplo n.º 31
0
from unittest import TestCase

from src.teacher import Teacher
from src.student import Student
from src.question import Question
from src.quiz import Quiz
from src.classroom import Classroom

jude = Student('Jude Arroyo')
carlee = Student('Carlee Holloway')
julia = Student('Julia Henderson')
earl = Student('Earl Christensen')

question_one = Question('What is the national sport in Japan?', 'Judo')
question_one.add_option('Judo')
question_one.add_option('Baseball')
question_one.add_option('Sumo Wrestling')

question_two = Question('How many minutes is a rugby match?', 80)
question_two.add_option(70)
question_two.add_option(80)
question_two.add_option(90)

question_three = Question(
    'Which car won Fernando Alonso his first tittle in Formula 1 with?',
    'Renault')
question_three.add_option('Renault')
question_three.add_option('Ford')
question_three.add_option('Peugeot')

question_four = Question('In which sport can you win the Davis Cup?', 'Tennis')
Exemplo n.º 32
0
 def setUp(self):
     self.stud = Student('Douglas', 'Detoni')