Ejemplo n.º 1
0
 def test_that_startline_gets_pickled(self):
     course = Course(self.filename)
     expected = {
         'lat_pin_1': -1.23,
         'lon_pin_1': 9.87,
         'lat_pin_2': 9.87,
         'lon_pin_2': 9.87,
         'start_from': 'North'
     }
     course.add_startline(-1.23, 9.87, 9.87, 9.87, 'North')
     course.pickle_startline()
     course = None
     course = Course(self.filename)
     actual = course.startline
     self.assertDictEqual(expected, actual)
Ejemplo n.º 2
0
def csv_to_list(imported_file):
    new_list = list([])

    with open(imported_file, "r") as file:
        lines = file.readlines()
        for line in lines:
            name = line.split("Student name: ")[1].split(", ")[0]
            gender = line.split("gender: ")[1].split(", ")[0]
            course_names = (line.split("course name: ")[1].split(", t")[0]).split(",")
            teachers = (line.split("eacher: ")[1].split(", e")[0]).split(",")
            all_etcs = (line.split("tcs: ")[1].split(", c")[0]).split(",")
            classrooms = (line.split("lassroom: ")[1].split(", g")[0]).split(",")
            grades = (line.split("rade: ")[1].split(", i")[0]).split(",")
            image_url = line.split("mage_url: ")[1]

            courses = []

            for x in range(0, 5):
                courses.append(Course(course_names[x], classrooms[x], 
                teachers[x], all_etcs[x], grades[x]))

            data_sheet = DataSheet(courses)
            student = Student(name, gender, data_sheet, image_url)

            new_list.append(student)

    return new_list
Ejemplo n.º 3
0
 def test_that_waypoints_gets_pickled(self):
     course = Course(self.filename)
     expected = {
         2: {
             'name': 'Pickle',
             'latitude': 0.00,
             'longitude': 0.00,
             'leave_to': 'anywhere',
             'passed': False,
             'next': False
         }
     }
     course.add_waypoint(2, 'name', 'Pickle')
     course.pickle_waypoints()
     course = None
     course = Course(self.filename)
     actual = course.waypoints
     self.assertDictEqual(expected, actual)
Ejemplo n.º 4
0
    def __init__(self):
        self.filename = 'RORC De Guingand Bowl Race 2017'
        self.course = Course(self.filename)

        self.course.add_start_time_UTC(datetime.datetime(2017, 5, 13, 8, 20))

        #Cowes RYS Startline
        self.course.add_startline(50.767, -1.301, 50.787, -1.309, 'West')

        self.course.add_waypoint(1, 'name', 'Cowes No.2 Buoy')
        self.course.add_waypoint(1, 'latitude', 50.768)
        self.course.add_waypoint(1, 'longitude', -1.298)

        self.course.add_waypoint(2, 'name', 'No Mans Land Fort')
        self.course.add_waypoint(2, 'latitude', 50.74)
        self.course.add_waypoint(2, 'longitude', -1.094)

        self.course.add_waypoint(3, 'name', 'Bembridge Ledge Buoy')
        self.course.add_waypoint(3, 'latitude', 50.686)
        self.course.add_waypoint(3, 'longitude', -1.047)

        self.course.add_waypoint(4, 'name', 'West Princessa Buoy')
        self.course.add_waypoint(4, 'latitude', 50.669)
        self.course.add_waypoint(4, 'longitude', -1.059)

        self.course.add_waypoint(5, 'name', 'St Catherines Light')
        self.course.add_waypoint(5, 'latitude', 50.568)
        self.course.add_waypoint(5, 'longitude', -1.30)

        self.course.add_waypoint(6, 'name', 'Needles Fairway')
        self.course.add_waypoint(6, 'latitude', 50.637)
        self.course.add_waypoint(6, 'longitude', -1.650)

        self.course.add_waypoint(7, 'name', 'North Head Buoy')
        self.course.add_waypoint(7, 'latitude', 50.7115)
        self.course.add_waypoint(7, 'longitude', -1.592)

        self.course.add_waypoint(8, 'name', 'East Shambles Buoy')
        self.course.add_waypoint(8, 'latitude', 50.521)
        self.course.add_waypoint(8, 'longitude', -2.335)

        self.course.add_waypoint(9, 'name', 'St Catherines Light')
        self.course.add_waypoint(9, 'latitude', 50.568)
        self.course.add_waypoint(9, 'longitude', -1.30)

        self.course.add_waypoint(10, 'name', 'New Ground Buoy')
        self.course.add_waypoint(10, 'latitude', 50.697)
        self.course.add_waypoint(10, 'longitude', -0.975)

        self.course.add_waypoint(11, 'name', 'No Mans Land Fort')
        self.course.add_waypoint(11, 'latitude', 50.74)
        self.course.add_waypoint(11, 'longitude', -1.094)

        self.course.add_waypoint(12, 'name', 'FINISH Mother Bank Buoy')
        self.course.add_waypoint(12, 'latitude', 50.758)
        self.course.add_waypoint(12, 'longitude', -1.186)
Ejemplo n.º 5
0
 def test_that_a_startline_can_be_added_to_course(self):
     course = Course()
     expected = {
         'lat_pin_1': 0.00,
         'lon_pin_1': 0.00,
         'lat_pin_2': 0.00,
         'lon_pin_2': 0.00,
         'start_from': 'West'
     }
     course.add_startline(0.00, 0.00, 0.00, 0.00, 'West')
     actual = course.startline
     self.assertDictEqual(expected, actual)
Ejemplo n.º 6
0
    def __init__(self):
        self.filename = 'RORC De Guingand Bowl Race 2017'
        self.course = Course(self.filename)

        self.course.add_start_time_UTC(datetime.datetime(2017, 5, 13, 8, 20))

        #Cowes RYS Startline
        self.course.add_startline(50.767, -1.301, 50.787, -1.309, 'West')

        self.course.add_waypoint(1, 'name', 'Snowden Buoy')
        self.course.add_waypoint(1, 'latitude', 50.77)
        self.course.add_waypoint(1, 'longitude', -1.2958)

        self.course.add_waypoint(2, 'name', 'No Mans Land Fort')
        self.course.add_waypoint(2, 'latitude', 50.7406)
        self.course.add_waypoint(2, 'longitude', -1.0933)

        self.course.add_waypoint(3, 'name', 'Owers Buoy')
        self.course.add_waypoint(3, 'latitude', 50.6432)
        self.course.add_waypoint(3, 'longitude', -0.6848)

        self.course.add_waypoint(4, 'name', 'St Catherines Point')
        self.course.add_waypoint(4, 'latitude', 50.5756)
        self.course.add_waypoint(4, 'longitude', -1.2978)

        self.course.add_waypoint(5, 'name', 'ODAS Buoy (Southern)')
        self.course.add_waypoint(5, 'latitude', 50.4335)
        self.course.add_waypoint(5, 'longitude', -1.81)

        self.course.add_waypoint(6, 'name', 'Poole Bar Buoy (No. 1)')
        self.course.add_waypoint(6, 'latitude', 50.6548)
        self.course.add_waypoint(6, 'longitude', -1.919)

        self.course.add_waypoint(7, 'name', 'SW Shingles Buoy')
        self.course.add_waypoint(7, 'latitude', 50.6548)
        self.course.add_waypoint(7, 'longitude', -1.6253)

        self.course.add_waypoint(8, 'name', 'ODAS Buoy (Northern)')
        self.course.add_waypoint(8, 'latitude', 50.5532)
        self.course.add_waypoint(8, 'longitude', -1.7195)

        self.course.add_waypoint(9, 'name', 'Poole Bar Buoy (No. 1)')
        self.course.add_waypoint(9, 'latitude', 50.6548)
        self.course.add_waypoint(9, 'longitude', -1.919)

        self.course.add_waypoint(10, 'name', 'North Head Buoy')
        self.course.add_waypoint(10, 'latitude', 50.7115)
        self.course.add_waypoint(10, 'longitude', -1.592)

        self.course.add_waypoint(11, 'name', 'FINISH - Lymington Bank Buoy')
        self.course.add_waypoint(11, 'latitude', 50.7183)
        self.course.add_waypoint(11, 'longitude', -1.5142)
Ejemplo n.º 7
0
 def test_that_a_waypoint_can_be_created(self):
     course = Course()
     expected = {
         1: {
             'name': 'unknown',
             'latitude': 0.00,
             'longitude': 0.00,
             'leave_to': 'anywhere',
             'passed': False,
             'next': False
         }
     }
     course.add_waypoint(1)
     actual = course.waypoints
     self.assertDictEqual(expected, actual)
Ejemplo n.º 8
0
 def test_that_waypoint_details_can_be_updated(self):
     course = Course()
     expected = {
         1: {
             'name': 'Waypoint1',
             'latitude': 0.00,
             'longitude': 0.00,
             'leave_to': 'anywhere',
             'passed': False,
             'next': False
         }
     }
     course.add_waypoint(1, 'name', 'Waypoint1')
     actual = course.waypoints
     self.assertDictEqual(expected, actual)
Ejemplo n.º 9
0
 def create_course(self, course_name, course_price, course_time):
     '''创建课程'''
     course_obj = Course(course_name, course_price, course_time)
     self.school_course[course_name] = course_obj
Ejemplo n.º 10
0
 def test_that_a_ValueError_is_rasied_if_an_invalid_key_is_passed_to_add_waypoints(
         self):
     course = Course()
     self.assertRaises(ValueError, course.add_waypoint, 1, 'invalid key',
                       20)
Ejemplo n.º 11
0
 def add_course(self, course_name, course_period, course_cost):
     self.course.append(Course(course_name, course_period, course_cost))
Ejemplo n.º 12
0
def generate_students(number):
    course_names = ["Security", "Typescript", "Kotlin"]
    genders = ["male", "female"]
    grades = ["-3", "00", "02", "4", "7", "10", "12"]
    etcs = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", 
    "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
    "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"]
    classRoom = ["A", "B", "C", "D", "E", "F"]
    teacher = ["Thomas", "Daniel", "Lars", "Jon", "Nikolai", "Palle"]

    for x in range(0, number):
        with open("week3.csv", "a") as file_obj:
            name = names.get_full_name()
            image_url = "".join(
                random.choice(string.ascii_lowercase) for i in range(15)
            )

            courses = list([])
            for x in range(0, 5):
                course = Course(
                    random.choice(course_names),
                    random.choice(classRoom),
                    random.choice(teacher),
                    random.choice(etcs),
                    random.choice(grades),
                )
                
                courses.append(course)

            data_sheet = DataSheet(courses)

            student = Student(name, random.choice(genders), data_sheet, image_url)

            text_to_file = "Student name: {stud_name}, gender: {stud_gender}, course name: {course_name}, teacher: {teacher}, etcs: {etcs}, classroom: {classroom}, grade: {grade}, image_url: {image_url}".format(
                stud_name=student.name,

                stud_gender=student.gender,

                course_name = data_sheet.courses[0].name + ", " +
                data_sheet.courses[1].name + ", " +
                data_sheet.courses[2].name + ", " +
                data_sheet.courses[3].name + ", " +
                data_sheet.courses[4].name,

                teacher=data_sheet.courses[0].teacher + ", " +
                data_sheet.courses[1].teacher + ", " +
                data_sheet.courses[2].teacher + ", " +
                data_sheet.courses[3].teacher + ", " +
                data_sheet.courses[4].teacher,

                etcs=data_sheet.courses[0].etcs + ", " +
                data_sheet.courses[1].etcs + ", " +
                data_sheet.courses[2].etcs + ", " +
                data_sheet.courses[3].etcs + ", " +
                data_sheet.courses[4].etcs,

                classroom=data_sheet.courses[0].classroom + ", " +
                data_sheet.courses[1].classroom + ", " +
                data_sheet.courses[2].classroom + ", " +
                data_sheet.courses[3].classroom + ", " +
                data_sheet.courses[4].classroom,

                grade=data_sheet.courses[0].grade + ", " +
                data_sheet.courses[1].grade + ", " +
                data_sheet.courses[2].grade + ", " +
                data_sheet.courses[3].grade + ", " +
                data_sheet.courses[4].grade,

                image_url=student.image_url,
            )

            file_obj.write(text_to_file + "\n")
Ejemplo n.º 13
0
 def test_ValueError_if_an_invalid_next_datatype_is_passed_to_add_waypoints(
         self):
     course = Course()
     self.assertRaises(ValueError, course.add_waypoint, 1, 'next', 'x')
Ejemplo n.º 14
0
 def create_course(self, name, period, price):  # 创建课程
     course_obj = Course(name, period, price)
     self.course[name] = course_obj
Ejemplo n.º 15
0
def create_test_data():
    schooldata = shelve.open(SCHOOL_DATADIR + "school.db",writeback = True)
    
    newschool1 = School("清华","北京")
    newschool2 = School("武大","武汉")
    newschool3 = School("川大","四川")
    
    newcourse1 = Course("java全站开发","5个月","20000元")
    newcourse2 = Course("python自动化运维","4个月","30000元")
    newcourse3 = Course("大数据","5个月","50000元")
    
    newteacher1 = Teacher("讲师马云A","123456","男","30","20000","13211114444")
    newteacher2 = Teacher("讲师马云B","123456","男","30","20000","13211114444")
    newteacher3 = Teacher("讲师马云C","123456","男","30","20000","13211114444")
    newteacher4 = Teacher("讲师马云D","123456","男","30","20000","13211114444")
    newteacher5 = Teacher("讲师马云E","123456","男","30","20000","13211114444")
    
    newgrade1 = Grade("1班","讲师马云A","java全站开发")
    newgrade2 = Grade("2班","讲师马云B","python自动化运维")
    newgrade3 = Grade("3班","讲师马云C","大数据")
    
    newstudent1 = Student("周杰伦1","123456","男","22","False")
    newstudent2 = Student("周杰伦2","123456","男","22","False")
    newstudent3 = Student("周杰伦3","123456","男","22","False")
    newstudent4 = Student("周杰伦4","123456","男","22","False")
    newstudent5 = Student("周杰伦5","123456","男","22","False")
    newstudent6 = Student("周杰伦6","123456","男","22","False")
    newstudent7 = Student("周杰伦7","123456","男","22","False")
    newstudent8 = Student("周杰伦8","123456","男","22","False")
    newstudent9 = Student("周杰伦9","123456","男","22","False")
    
    newgrade1.grade_student["周杰伦1"] = newstudent1
    newgrade1.grade_student["周杰伦2"] = newstudent2
    newgrade1.grade_student["周杰伦3"] = newstudent3
    newgrade1.grade_student["周杰伦4"] = newstudent4
    newgrade1.grade_student["周杰伦5"] = newstudent5
    newgrade1.grade_student["周杰伦6"] = newstudent6
    newgrade1.grade_student["周杰伦7"] = newstudent7
    newgrade1.grade_student["周杰伦8"] = newstudent8
    newgrade1.grade_student["周杰伦9"] = newstudent9
    
    newschool1.school_course["java全站开发"] = newcourse1
    newschool1.school_course["python自动化运维"] = newcourse2
    newschool1.school_course["大数据"] = newcourse3

    newschool1.school_grade["1班"] = newgrade1
    newschool1.school_grade["2班"] = newgrade2
    newschool1.school_grade["3班"] = newgrade3
    
    
    newschool1.school_teacher["讲师马云A"] = newteacher1
    newschool1.school_teacher["讲师马云B"] = newteacher2
    newschool1.school_teacher["讲师马云C"] = newteacher3
    newschool1.school_teacher["讲师马云D"] = newteacher4
    newschool1.school_teacher["讲师马云E"] = newteacher5
    
    
    schooldata["清华"] = newschool1
    schooldata["武大"] = newschool2
    schooldata["川大"] = newschool3
    schooldata.close()
Ejemplo n.º 16
0
 def create_course(self,course_name,course_price,course_period):
     course_obj=Course(course_name,course_price,course_period)
     self.school_course[course_name]=course_obj
Ejemplo n.º 17
0
 def test_ValueError_if_an_invalid_leave_to_value_is_passed_to_add_waypoints(
         self):
     course = Course()
     self.assertRaises(ValueError, course.add_waypoint, 1, 'leave_to', 'x')
Ejemplo n.º 18
0
 def test_ValueError_if_an_invalid_start_from_value_is_passed_to_add_startline(
         self):
     course = Course()
     self.assertRaises(ValueError, course.add_startline, 0.00, 0.00, 0.00,
                       0.00, 'x')
Ejemplo n.º 19
0
 def test_ValueError_if_an_invalid_lon_pin_2_datatype_is_passed_to_add_startline(
         self):
     course = Course()
     self.assertRaises(ValueError, course.add_startline, 0.00, 0.00, 0.00,
                       'x', 'West')
Ejemplo n.º 20
0
 def create_course(self, course_name, course_price, course_time):
     """创建课程"""
     course_obj = Course(course_name, course_price, course_time)
     self.school_course[course_name] = course_obj
Ejemplo n.º 21
0
 def create_course(self, course_name, course_price, course_time):
     coures_obj = Course(course_name, course_price, course_time)
     self.school_course[course_name] = coures_obj