def test_notbelonging(self): metal = Course('metalli', 'beep.com') courseinside = Course('polimeri', 'beep.com') other = Course('other', 'doesntmatter') courses = Courses() courses.append(courseinside, other) assert metal not in courses
def test_belonging(self): metal = Course('metalli', 'beep.com') metalinside = Course('metalli', 'beep.com') other = Course('other', 'doesntmatter') courses = Courses() courses.append(metalinside, other) assert metal in courses
def test_simplifycoursewithaccents(self): course = Course({'name': "[2017-18] - PROBABILITÀ E STATISTICA PER L'INFORMATICA [ GIUSEPPINA GUATTERI ]", 'friendlyURL': 'beep.com', 'classPK': 1}) assert course.simplify_name(course.name) == "Probabilità E Statistica"\ " Per L'Informatica"
def test_hash_not_depending_on_order(self): oneorder = Courses() otherorder = Courses() metal = Course('metalli', 'beep.com') polim = Course('polimeri', 'beep.it') oneorder.append(metal, polim) otherorder.append(polim, metal) assert hash(oneorder) == hash(otherorder)
def test_simplifycoursewithspecialchars(self): course = Course({'name': "[2018-19] - SISTEMI INFORMATIVI (PER IL " "SETTORE DELL'INFORMAZIONE) [ MONICA VITALI ] " "classe-694572", 'friendlyURL': 'beep.com', 'classPK': 1}) assert course.simplify_name(course.name) == "Sistemi Informativi"
def test_remove(self): all = Courses() one = Courses() metal = Course('metalli', 'beep.com') other = Course('other', 'doesntmatter') all.append(metal, other) one.append(other) all.remove(metal) assert all == one
def step_impl(context): new_course = Course('newcourse', 'fakelink') common_course = Course('common', 'commonlink') guy = User('fakeid', 'fakepwd') guy.available_courses.append(new_course, common_course) context.guy = guy online_courses = Courses() online_courses.append(common_course) context.online_courses = online_courses
def test_sync_courses_remove(self): guy = User('fakeid', 'fakepwd') metal = Course('metalli', 'beep.com') other = Course('other', 'doesntmatter') online = Courses() online.append(metal) guy.available_courses.append(metal, other) guy.sync_available_courses(online) assert guy.available_courses == online
def test_append(self): metal = Course('metalli', 'beep.com') other = Course('other', 'doesntmatter') oneatatime = Courses() # append in two steps oneatatime.append(metal) oneatatime.append(other) twocourses = Courses() twocourses.append(other, metal) # append in one step assert twocourses == oneatatime
def test_getitem(self): a = CourseFile({'title': 'a', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 1990}) metal = Course({'name': 'metalli', 'friendlyURL': 'beep.com', 'classPK': 1}) metal.append(a) assert metal['a'] == a
def test__contains__a_file(self): onefile = CourseFile({'title': 'a', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 1990}) metal = Course({'name': 'metalli', 'friendlyURL': 'beep.com', 'classPK': 1}) metal.append(onefile) assert onefile in metal
def test_getitem_raises_keyerror(self): with pytest.raises(KeyError): a = CourseFile({'title': 'a', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 1990}) metal = Course({'name': 'metalli', 'friendlyURL': 'beep.com', 'classPK': 1}) metal.append(a) metal['b']
def test_difference(self): offline_metal = Course('metalli', 'beep.com') offline_polim = Course('polimeri', 'beep.it') metal = Course('metalli', 'beep.com') polim = Course('polimeri', 'beep.it') offline = Courses() offline.append(offline_polim, offline_metal) online = Courses() online.append(metal, polim) for course in online: print('online {}'.format(course.name)) for course in offline: print('offline {}'.format(course.name)) assert online - offline == []
def test_equality(self): a = CourseFile('a', 'url', '1990') b = CourseFile('b', 'url', '111') c = CourseFile('c', 'url', '1111') offline_metal = Course('metalli', 'beep.com') metal = Course('metalli', 'beep.com') offline_metal.append(a, b) metal.append(a, b, c) assert metal == offline_metal
def test_difference(self): a = CourseFile('a', 'url', '1990') b = CourseFile('b', 'url', '111') c = CourseFile('c', 'url', '1111') e = CourseFile('e', 'url', '19') offline_metal = Course('metalli', 'beep.com') metal = Course('metalli', 'beep.com') offline_metal.append(a, b, c) metal.append(a, b, e) assert set(metal - offline_metal) == set([e])
def test_difference(self): a = CourseFile({'title': 'a', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 1990}) b = CourseFile({'title': 'b', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 111}) c = CourseFile({'title': 'c', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 111}) e = CourseFile({'title': '3', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 19}) offline_metal = Course({'name': 'metalli', 'friendlyURL': 'beep.com', 'classPK': 1}) metal = Course({'name': 'metalli', 'friendlyURL': 'beep.com', 'classPK': 1}) offline_metal.append(a, b, c) metal.append(a, b, e) assert set(metal-offline_metal) == set([e])
def test_equality(self): a = CourseFile({'title': 'a', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 1990}) b = CourseFile({'title': 'b', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 111}) c = CourseFile({'title': 'c', 'groupId': 5, 'uuid': '50-ddf-kek', 'size': 111}) offline_metal = Course({'name': 'metalli', 'friendlyURL': 'beep.com', 'classPK': 1}) metal = Course({'name': 'metalli', 'friendlyURL': 'beep.com', 'classPK': 1}) offline_metal.append(a, b) metal.append(a, b, c) assert metal == offline_metal
def test_simplifycoursewithoutyear(self): course = Course({'name': 'RETI LOGICHE [ FABRIZIO FERRANDI ]', 'friendlyURL': 'beep.com', 'classPK': 1}) assert course.simplify_name(course.name) == "Reti Logiche"
def test_simplifysimplename(self): course = Course({'name': '[2014-15] - SOME STUFF [ A PROFESSOR ]', 'friendlyURL': 'beep.com', 'classPK': 1}) assert course.simplify_name(course.name) == "Some Stuff"
def step_impl(context): guy = User('fakeid', 'fakepwd') course_a = Course('a', 'alink') course_b = Course('b', 'blink') guy.available_courses.append(course_a, course_b) context.courses = guy.available_courses
def test__contains__a_file(self): onefile = CourseFile('a', 'url', '1990') metal = Course('metalli', 'beep.com') metal.append(onefile) assert onefile in metal
def test_simplifynamewithsquarebrackets(self): course = Course( '[2014-15] - OTTICA FISICA E TECNOLOGIE OTTICHE [C.I.] [ INGEGNERIA FISICA ]', 'beep.com') assert course.simplify_name( course.name) == "Ottica Fisica E Tecnologie Ottiche"
def step_impl(context): fake_course = Course('fakename', 'fakelink') file_a = CourseFile('filea', '03/11/14 12.33') file_b = CourseFile('fileb', '06/09/14 11.25') fake_course.append(file_a, file_b) context.selected_course = fake_course
def test_simplify_mems(self): course = Course( '[2014-15] - MICRO ELECTRO MECHANICAL SYSTEMS (MEMS) [ ALBERTO CORIGLIANO ]', 'beep.com') assert course.simplify_name( course.name) == "Micro Electro Mechanical Systems"
def test__init__(self): metal = Course('metalli', 'beep.com') assert hasattr(metal, 'elements')
def test_getitem(self): a = CourseFile('a', 'url', '1990') metal = Course('metalli', 'beep.com') metal.append(a) assert metal['a'] == a
def test_simplify_mems(self): course = Course({'name': '[2014-15] - MICRO ELECTRO MECHANICAL SYSTEMS (MEMS) [ ALBERTO CORIGLIANO ]', 'friendlyURL': 'beep.com', 'classPK': 1}) assert course.simplify_name(course.name) == "Micro Electro Mechanical Systems"
def test_inequality(self): other = Course('thing', 'beep.com') metal = Course('metalli', 'beep.com') assert metal != other
def test_cannotsimplifyname(self): course = Course('Metid', 'beep.com') assert course.simplify_name(course.name) == "Metid"
def test_return_hash(self): courses = Courses() courses.append(Course('metalli', 'beep.com')) assert hash(courses) is not None
def test__repr__(self): metal = Course('metalli', 'beep.com') assert repr(metal) == "Course metalli"
def test_ignorebeepcourse(self): clean_list = [ Course( '[2014-15] - ADVANCED CHEMISTRY FOR MATERIALS ENGINEERING [ MATERIALS ENGINEERING AND NANOTECHNOLOGY ]', 'beep.com'), Course( '[2014-15] - DURABILITY OF MATERIALS [ MATERIALS ENGINEERING AND NANOTECHNOLOGY ]', 'beep.com'), Course( '[2014-15] - FAILURE AND CONTROL OF METALS [ MAURIZIO VEDANI ]', 'beep.com'), Course( '[2014-15] - MATHEMATICAL METHODS FOR MATERIALS ENGINEERING [ MICHELE DI CRISTO ]', 'beep.com'), Course( '[2014-15] - MECHANICAL BEHAVIOUR OF MATERIALS [ LAURA VERGANI ]', 'beep.com'), Course( '[2014-15] - MICRO ELECTRO MECHANICAL SYSTEMS (MEMS) [ ALBERTO CORIGLIANO ]', 'beep.com'), Course( '[2014-15] - PHYSICAL PROPERTIES OF MOLECULAR MATERIALS [ MATTEO MARIA SAVERIO TOMMASINI ]', 'beep.com'), Course('[2014-15] - PHYSICS OF NANOSTRUCTURES [ CARLO S. CASARI ]', 'beep.com'), Course('[2014-15] - SOLID STATE PHYSICS [ CARLO ENRICO BOTTANI ]', 'beep.com'), Course( '[2014-15] - STRUCTURAL CHEMISTRY OF MATERIALS [ GUIDO RAOS ]', 'beep.com'), ] clean_courses = Courses() clean_courses.append(*clean_list) # the following file is an exact copy of what you get online. # It's a one-line document path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'courses-page.html') with open(path) as fake_courses: text = fake_courses.read() user = User("doesn't matter", 'nope') temp_courses = user._courses_scraper(text) courses = Courses() for elem in temp_courses: course = Course(elem[0], elem[1]) courses.append(course) assert courses == clean_courses
def test_getitem_raises_keyerror(self): with pytest.raises(KeyError): a = CourseFile('a', 'url', '1990') metal = Course('metalli', 'beep.com') metal.append(a) metal['b']
def test__doesnt_contain__a_file(self): onefile = CourseFile('a', 'url', '1990') metal = Course('metalli', 'beep.com') assert onefile not in metal
def test_cannotsimplifyname(self): course = Course({'name': 'Metid', 'friendlyURL': 'beep.com', 'classPK': 1}) assert course.simplify_name(course.name) == "Metid"
def test__len__(self): courses = Courses() courses.append(Course('metalli', 'beep.com'), Course('other', 'doesntmatter')) assert len(courses) == 2
def test_simplifynamewithsquarebrackets(self): course = Course({'name': '[2014-15] - OTTICA FISICA E TECNOLOGIE OTTICHE [C.I.] [ INGEGNERIA FISICA ]', 'friendlyURL': 'beep.com', 'classPK': 1}) assert course.simplify_name(course.name) == "Ottica Fisica E Tecnologie Ottiche"
def test_simplifysimplename(self): course = Course('[2014-15] - SOME STUFF [ A PROFESSOR ]', 'beep.com') assert course.simplify_name(course.name) == "Some Stuff"