def setUp(self): ''' Add dummy modules and mountings into database, Then retrieve all fixed module mountings from database ''' self.fixed_mounting_handler = Fixed() self.current_ay = model.get_current_ay() model.add_module('BB1001', 'Dummy Module 1', 'This module is mounted in both semesters.', 1, 'Active') model.add_module('BB1002', 'Dummy Module 2', 'This module is mounted in semester 1 only.', 2, 'Active') model.add_module('BB1003', 'Dummy Module 3', 'This module is mounted in semester 2 only.', 3, 'Active') model.add_module( 'BB1004', 'Dummy Module 4', 'This module is mounted in not mounted in any semester.', 4, 'Active') model.add_fixed_mounting('BB1001', self.current_ay + ' Sem 1', 10) model.add_fixed_mounting('BB1001', self.current_ay + ' Sem 2', 20) model.add_fixed_mounting('BB1002', self.current_ay + ' Sem 1', 30) model.add_fixed_mounting('BB1003', self.current_ay + ' Sem 2', 40) self.fixed_mounting_handler.populate_module_code_and_name() self.fixed_mounting_handler.populate_module_ay_sem_data() assert_true(len(self.fixed_mounting_handler.full_mounting_plan) > 0)
def setUp(self): ''' Add dummy modules and mountings into database ''' self.fixed_mounting_handler = Fixed() self.current_ay = model.get_current_ay() self.tentative_mounting_handler = Tentative() self.next_ay = self.get_next_ay(self.current_ay) self.selected_tenta_mountings = \ model.get_all_tenta_mounted_modules_of_selected_ay(self.next_ay) # Dummy modules model.add_module('BB1001', 'Dummy Module 1', 'This module is mounted in both sems in both AYs.', 1, 'Active') model.add_module('BB1002', 'Dummy Module 2', 'This module is mounted in sem 1 only, in both AYs.', 2, 'Active') model.add_module('BB1003', 'Dummy Module 3', 'This module is mounted in sem 2 only, in both AYs.', 3, 'Active') model.add_module('BB1004', 'Dummy Module 4', 'This module is not mounted in any sem, in both AYs.', 4, 'Active') model.add_module('BB9999', 'Dummy Module X', 'This module is mounted 20 years in the future!', 0, 'Active') # Dummy fixed mountings model.add_fixed_mounting('BB1001', self.current_ay+' Sem 1', 10) model.add_fixed_mounting('BB1001', self.current_ay+' Sem 2', 20) model.add_fixed_mounting('BB1002', self.current_ay+' Sem 1', 30) model.add_fixed_mounting('BB1003', self.current_ay+' Sem 2', 40) self.load_fixed_full_mounting_plan() # Dummy tentative mountings model.add_tenta_mounting('BB1001', self.next_ay+' Sem 1', 10) model.add_tenta_mounting('BB1001', self.next_ay+' Sem 2', 20) model.add_tenta_mounting('BB1002', self.next_ay+' Sem 1', 30) model.add_tenta_mounting('BB1003', self.next_ay+' Sem 2', 40) model.add_tenta_mounting('BB9999', 'AY 36/37 Sem 1', 999) self.load_tenta_full_mounting_plan()
def get_modules_with_modified_mounting(self): ''' Get all modules whose mounting has been modified in a future AY. Return the module code, current AY-Sem, target AY-Sem, and mounting change ''' # Generate fixed mounting plan fixed_mounting_handler = Fixed() current_ay = model.get_current_ay() fixed_mounting_handler.populate_module_code_and_name() fixed_mounting_handler.populate_module_ay_sem_data() fixed_full_mounting_plan = fixed_mounting_handler.full_mounting_plan modified_modules = [] target_ay = current_ay # Loop through each future AY for i in range(model.get_number_of_ay_in_system() - 1): target_ay = model.get_next_ay(target_ay) # Generate tentative mounting plan tenta_mounting_handler = Tentative() tenta_mounting_handler.populate_module_code_and_name() tenta_mounting_handler.populate_module_ay_sem_data(target_ay) tenta_full_mounting_plan = tenta_mounting_handler.full_mounting_plan # Compare the fixed and tentative mounting of each module for each semester # to see if there is any difference (if there is, means it's modified) for i in range(len(fixed_full_mounting_plan)): fixed_subplan = fixed_full_mounting_plan[i] tenta_subplan = tenta_full_mounting_plan[i] module_code = fixed_subplan[0] module_name = fixed_subplan[1] fixed_sem_1_mounting = fixed_subplan[2] tenta_sem_1_mounting = tenta_subplan[2] fixed_sem_2_mounting = fixed_subplan[3] tenta_sem_2_mounting = tenta_subplan[3] if tenta_sem_1_mounting == 0: modified_modules.append([ module_code, module_name, current_ay + " Sem 1", target_ay + " Sem 1", 0 ]) # Mounted --> Unmounted elif tenta_sem_1_mounting == 1 and fixed_sem_1_mounting == -1: modified_modules.append([ module_code, module_name, current_ay + " Sem 1", target_ay + " Sem 1", 1 ]) # Unmounted --> Mounted if tenta_sem_2_mounting == 0: modified_modules.append([ module_code, module_name, current_ay + " Sem 2", target_ay + " Sem 2", 0 ]) # Mounted --> Unmounted elif tenta_sem_2_mounting == 1 and fixed_sem_2_mounting == -1: modified_modules.append([ module_code, module_name, current_ay + " Sem 2", target_ay + " Sem 2", 1 ]) # Unmounted --> Mounted return modified_modules
def populate_module_ay_sem_data(self, selected_ay): ''' Populate each subplan with sem 1 and sem 2 mounting values ''' tenta_full_mounting_plan = self.full_mounting_plan mounted_module_infos = model.get_all_tenta_mounted_modules_of_selected_ay( selected_ay) subplan_index = 0 curr_subplan = tenta_full_mounting_plan[subplan_index] # Mark module that are mounted for info in mounted_module_infos: code = info[0] curr_module_code = curr_subplan[0] while code != curr_module_code: subplan_index += 1 curr_subplan = tenta_full_mounting_plan[subplan_index] curr_module_code = curr_subplan[0] ay_sem = info[2] sem = ay_sem[9:14] quota = info[3] if sem == "Sem 1": curr_subplan[2] = 1 curr_subplan[4] = quota elif sem == "Sem 2": curr_subplan[3] = 1 curr_subplan[5] = quota # Generate full mounting plan for fixed mountings fixed_mounting_handler = Fixed() fixed_mounting_handler.populate_module_code_and_name() fixed_mounting_handler.populate_module_ay_sem_data() fixed_full_mounting_plan = fixed_mounting_handler.full_mounting_plan # Mark module that are unmounted # (i.e. mounted in current AY, but will no longer be mounted in future AY) for i in range(len(fixed_full_mounting_plan)): fixed_subplan = fixed_full_mounting_plan[i] tenta_subplan = tenta_full_mounting_plan[i] fixed_sem_1_mounting = fixed_subplan[2] tenta_sem_1_mounting = tenta_subplan[2] fixed_sem_2_mounting = fixed_subplan[3] tenta_sem_2_mounting = tenta_subplan[3] if fixed_sem_1_mounting == 1 and tenta_sem_1_mounting == -1: tenta_full_mounting_plan[i][2] = 0 if fixed_sem_2_mounting == 1 and tenta_sem_2_mounting == -1: tenta_full_mounting_plan[i][3] = 0 student_stats = model.get_student_stats_for_all_mods() subplan_index = 0 curr_subplan = tenta_full_mounting_plan[subplan_index] selected_ay = model.get_next_ay(model.get_current_ay()) for stat in student_stats: code = stat[1] curr_module_code = curr_subplan[0] while code != curr_module_code: subplan_index += 1 curr_subplan = tenta_full_mounting_plan[subplan_index] curr_module_code = curr_subplan[0] ay_sem = stat[2] number_of_students = stat[0] if ay_sem == selected_ay + " Sem 1": curr_subplan[6] = number_of_students elif ay_sem == selected_ay + " Sem 2": curr_subplan[7] = number_of_students self.full_mounting_plan = tenta_full_mounting_plan
class TestCode(object): ''' This class runs the test cases related to tentative module mountings. ''' def __init__(self): self.number_of_tests_left = None self.fixed_mounting_handler = None self.tentative_mounting_handler = None self.current_ay = None self.next_ay = None self.selected_tenta_mountings = None def get_next_ay(self, ay): ''' Return the AY that comes after the current AY ''' ay = ay.split(' ')[1].split('/') return 'AY ' + str(int(ay[0])+1) + '/' + str(int(ay[1])+1) def setUp(self): ''' Add dummy modules and mountings into database ''' self.fixed_mounting_handler = Fixed() self.current_ay = model.get_current_ay() self.tentative_mounting_handler = Tentative() self.next_ay = self.get_next_ay(self.current_ay) self.selected_tenta_mountings = \ model.get_all_tenta_mounted_modules_of_selected_ay(self.next_ay) # Dummy modules model.add_module('BB1001', 'Dummy Module 1', 'This module is mounted in both sems in both AYs.', 1, 'Active') model.add_module('BB1002', 'Dummy Module 2', 'This module is mounted in sem 1 only, in both AYs.', 2, 'Active') model.add_module('BB1003', 'Dummy Module 3', 'This module is mounted in sem 2 only, in both AYs.', 3, 'Active') model.add_module('BB1004', 'Dummy Module 4', 'This module is not mounted in any sem, in both AYs.', 4, 'Active') model.add_module('BB9999', 'Dummy Module X', 'This module is mounted 20 years in the future!', 0, 'Active') # Dummy fixed mountings model.add_fixed_mounting('BB1001', self.current_ay+' Sem 1', 10) model.add_fixed_mounting('BB1001', self.current_ay+' Sem 2', 20) model.add_fixed_mounting('BB1002', self.current_ay+' Sem 1', 30) model.add_fixed_mounting('BB1003', self.current_ay+' Sem 2', 40) self.load_fixed_full_mounting_plan() # Dummy tentative mountings model.add_tenta_mounting('BB1001', self.next_ay+' Sem 1', 10) model.add_tenta_mounting('BB1001', self.next_ay+' Sem 2', 20) model.add_tenta_mounting('BB1002', self.next_ay+' Sem 1', 30) model.add_tenta_mounting('BB1003', self.next_ay+' Sem 2', 40) model.add_tenta_mounting('BB9999', 'AY 36/37 Sem 1', 999) self.load_tenta_full_mounting_plan() def tearDown(self): ''' Clean up the database after all test cases are ran ''' model.delete_fixed_mounting('BB1001', self.current_ay+' Sem 1') model.delete_fixed_mounting('BB1001', self.current_ay+' Sem 2') model.delete_fixed_mounting('BB1002', self.current_ay+' Sem 1') model.delete_fixed_mounting('BB1003', self.current_ay+' Sem 2') model.delete_tenta_mounting('BB1001', self.next_ay+' Sem 1') model.delete_tenta_mounting('BB1001', self.next_ay+' Sem 2') model.delete_tenta_mounting('BB1002', self.next_ay+' Sem 1') model.delete_tenta_mounting('BB1003', self.next_ay+' Sem 2') model.delete_tenta_mounting('BB9999', 'AY 36/37 Sem 1') model.delete_module('BB1001') model.delete_module('BB1002') model.delete_module('BB1003') model.delete_module('BB1004') model.delete_module('BB9999') def load_fixed_full_mounting_plan(self): ''' Retrieve fixed mounting data from database and generate full mounting plan ''' self.fixed_mounting_handler.populate_module_code_and_name() self.fixed_mounting_handler.populate_module_ay_sem_data() assert_true(len(self.fixed_mounting_handler.full_mounting_plan) > 0) def load_tenta_full_mounting_plan(self): ''' Retrieve tentative mounting data from database and generate full mounting plan ''' self.tentative_mounting_handler.populate_module_code_and_name() self.tentative_mounting_handler.populate_module_ay_sem_data(self.next_ay) assert_true(len(self.tentative_mounting_handler.full_mounting_plan) > 0) def test_tenta_mountings_of_selected_ay(self): ''' Test that a list of tentative mountings of selected AY only contains mountings from the same AY ''' selected_ay = self.next_ay mounted_module_infos = self.selected_tenta_mountings is_same_ay = True for info in mounted_module_infos: ay = info[2][0:8] if ay != selected_ay: is_same_ay = False break assert_true(is_same_ay) def test_tenta_mounting_appear_in_correct_ay(self): ''' Test that a tentative mounting will only appear in the tentative mounting list of its AY ''' test_module_code = "BB9999" mounted_module_infos = self.selected_tenta_mountings # BB9999 should NOT appear in tentative list for next AY is_in_list = False for info in mounted_module_infos: if info[0] == test_module_code: is_in_list = True break assert_false(is_in_list) # BB9999 should appear in tentative list for AY 36/37 mounted_module_infos = model.get_all_tenta_mounted_modules_of_selected_ay("AY 36/37") is_in_list = False for info in mounted_module_infos: if info[0] == test_module_code: is_in_list = True break assert_true(is_in_list) def test_mounted_in_both_sems(self): ''' Tests that a module that is mounted in both sems in both AYs will have the tentative-mounting values '1' and '1' ''' full_mounting_plan = self.tentative_mounting_handler.full_mounting_plan test_module_code = "BB1001" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 1) assert_equal(test_module_sem_2, 1) def test_mounted_in_sem_1_only(self): ''' Tests that a module that is mounted in sem 1 only, in both AYs, will have the tentative-mounting values '1' and '-1' ''' full_mounting_plan = self.tentative_mounting_handler.full_mounting_plan test_module_code = "BB1002" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 1) assert_equal(test_module_sem_2, -1) def test_mounted_in_sem_2_only(self): ''' Tests that a module that is mounted in sem 2 only, in both AYs, will have the tentative-mounting values '-1' and '1' ''' full_mounting_plan = self.tentative_mounting_handler.full_mounting_plan test_module_code = "BB1003" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, -1) assert_equal(test_module_sem_2, 1) def test_not_mounted(self): ''' Tests that a module that is not mounted in any sem, in both AYs, will have the tentative-mounting values '-1' and '-1' ''' full_mounting_plan = self.tentative_mounting_handler.full_mounting_plan test_module_code = "BB1004" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, -1) assert_equal(test_module_sem_2, -1) def test_unmounted_from_sem_1(self): ''' Tests that a module that is unmounted from sem 1 will have the tentative-mounting value of '0' for sem 1 ''' model.delete_tenta_mounting('BB1001', self.next_ay+' Sem 1') model.delete_tenta_mounting('BB1002', self.next_ay+' Sem 1') self.load_tenta_full_mounting_plan() full_mounting_plan = self.tentative_mounting_handler.full_mounting_plan test_module_code = "BB1001" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 0) assert_equal(test_module_sem_2, 1) test_module_code = "BB1002" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 0) assert_equal(test_module_sem_2, -1) model.add_tenta_mounting('BB1001', self.next_ay+' Sem 1', 10) model.add_tenta_mounting('BB1002', self.next_ay+' Sem 1', 30) self.load_tenta_full_mounting_plan() def test_unmounted_from_sem_2(self): ''' Tests that a module that is unmounted from sem 2 will have the tentative-mounting value of '0' for sem 2 ''' model.delete_tenta_mounting('BB1001', self.next_ay+' Sem 2') model.delete_tenta_mounting('BB1003', self.next_ay+' Sem 2') self.load_tenta_full_mounting_plan() full_mounting_plan = self.tentative_mounting_handler.full_mounting_plan test_module_code = "BB1001" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 1) assert_equal(test_module_sem_2, 0) test_module_code = "BB1003" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, -1) assert_equal(test_module_sem_2, 0) model.add_tenta_mounting('BB1001', self.next_ay+' Sem 2', 20) model.add_tenta_mounting('BB1003', self.next_ay+' Sem 2', 40) self.load_tenta_full_mounting_plan() def test_unmounted_from_both_sems(self): ''' Tests that a module that is unmounted from both sems will have the tentative-mounting values '0' and '0' ''' model.delete_tenta_mounting('BB1001', self.next_ay+' Sem 1') model.delete_tenta_mounting('BB1001', self.next_ay+' Sem 2') self.load_tenta_full_mounting_plan() full_mounting_plan = self.tentative_mounting_handler.full_mounting_plan test_module_code = "BB1001" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 0) assert_equal(test_module_sem_2, 0) model.add_tenta_mounting('BB1001', self.next_ay+' Sem 1', 10) model.add_tenta_mounting('BB1001', self.next_ay+' Sem 2', 20) self.load_tenta_full_mounting_plan()
def GET(self, *test_data): ''' Renders the oversubscribed modules page if users requested for the page through the GET method. ''' if test_data: target_ay_sem = test_data[0] else: if not session.validate_session(): raise web.seeother('/login') input_data = model.validate_input(web.input(), ["aysem"], aysem_specific=False, attr_required=False) try: target_ay_sem = input_data.aysem except AttributeError: target_ay_sem = model.get_current_ay_sem() all_ay_sems = model.get_all_ay_sems() #list_of_oversub_mod = model.get_oversub_mod() list_of_oversub_mod = [] current_ay = model.get_current_ay() if target_ay_sem[0:8] == current_ay: fixed_mounting_handler = Fixed() fixed_mounting_handler.GET(to_render=False, logged_in=True) full_mounting_plan = fixed_mounting_handler.full_mounting_plan if target_ay_sem[9:15] == "Sem 1": for subplan in full_mounting_plan: module_code = subplan[0] module_name = subplan[1] sem1_quota = subplan[4] sem1_num_students = subplan[6] if ((sem1_quota != '?' and sem1_quota != '-') \ and sem1_num_students > sem1_quota) \ or ((sem1_quota == '?' or sem1_quota == '-') and sem1_num_students > 0): if sem1_quota == '?' or sem1_quota == '-': oversub_amount = sem1_num_students else: oversub_amount = sem1_num_students - sem1_quota list_of_oversub_mod.append( (module_code, module_name, target_ay_sem, sem1_quota, sem1_num_students, oversub_amount)) else: for subplan in full_mounting_plan: module_code = subplan[0] module_name = subplan[1] sem2_quota = subplan[5] sem2_num_students = subplan[7] if ((sem2_quota != '?' and sem2_quota != '-') \ and sem2_num_students > sem2_quota) \ or ((sem2_quota == '?' or sem2_quota == '-') and sem2_num_students > 0): if sem2_quota == '?' or sem2_quota == '-': oversub_amount = sem2_num_students else: oversub_amount = sem2_num_students - sem2_quota list_of_oversub_mod.append( (module_code, module_name, target_ay_sem, sem2_quota, sem2_num_students, oversub_amount)) else: tenta_mounting_handler = Tentative() tenta_mounting_handler.GET(to_render=False, logged_in=True) full_mounting_plan = tenta_mounting_handler.full_mounting_plan if target_ay_sem[9:15] == "Sem 1": for subplan in full_mounting_plan: module_code = subplan[0] module_name = subplan[1] sem1_quota = subplan[4] sem1_num_students = subplan[6] if ((sem1_quota != '?' and sem1_quota != '-') \ and sem1_num_students > sem1_quota) \ or ((sem1_quota == '?' or sem1_quota == '-') and sem1_num_students > 0): if sem1_quota == '?' or sem1_quota == '-': oversub_amount = sem1_num_students else: oversub_amount = sem1_num_students - sem1_quota list_of_oversub_mod.append( (module_code, module_name, target_ay_sem, sem1_quota, sem1_num_students, oversub_amount)) else: for subplan in full_mounting_plan: module_code = subplan[0] module_name = subplan[1] sem2_quota = subplan[5] sem2_num_students = subplan[7] if ((sem2_quota != '?' and sem2_quota != '-') \ and sem2_num_students > sem2_quota) \ or ((sem2_quota == '?' or sem2_quota == '-') and sem2_num_students > 0): if sem2_quota == '?' or sem2_quota == '-': oversub_amount = sem2_num_students else: oversub_amount = sem2_num_students - sem2_quota list_of_oversub_mod.append( (module_code, module_name, target_ay_sem, sem2_quota, sem2_num_students, oversub_amount)) if not test_data: return RENDER.oversubscribedModules(list_of_oversub_mod, all_ay_sems, target_ay_sem) else: return list_of_oversub_mod
class TestCode(object): ''' This class runs the test cases related to fixed module mountings. ''' def __init__(self): self.number_of_tests_left = None self.fixed_mounting_handler = None self.current_ay = None def setUp(self): ''' Add dummy modules and mountings into database, Then retrieve all fixed module mountings from database ''' self.fixed_mounting_handler = Fixed() self.current_ay = model.get_current_ay() model.add_module('BB1001', 'Dummy Module 1', 'This module is mounted in both semesters.', 1, 'Active') model.add_module('BB1002', 'Dummy Module 2', 'This module is mounted in semester 1 only.', 2, 'Active') model.add_module('BB1003', 'Dummy Module 3', 'This module is mounted in semester 2 only.', 3, 'Active') model.add_module( 'BB1004', 'Dummy Module 4', 'This module is mounted in not mounted in any semester.', 4, 'Active') model.add_fixed_mounting('BB1001', self.current_ay + ' Sem 1', 10) model.add_fixed_mounting('BB1001', self.current_ay + ' Sem 2', 20) model.add_fixed_mounting('BB1002', self.current_ay + ' Sem 1', 30) model.add_fixed_mounting('BB1003', self.current_ay + ' Sem 2', 40) self.fixed_mounting_handler.populate_module_code_and_name() self.fixed_mounting_handler.populate_module_ay_sem_data() assert_true(len(self.fixed_mounting_handler.full_mounting_plan) > 0) def tearDown(self): ''' Clean up the database after all test cases are ran ''' model.delete_fixed_mounting('BB1001', self.current_ay + ' Sem 1') model.delete_fixed_mounting('BB1001', self.current_ay + ' Sem 2') model.delete_fixed_mounting('BB1002', self.current_ay + ' Sem 1') model.delete_fixed_mounting('BB1003', self.current_ay + ' Sem 2') model.delete_module('BB1001') model.delete_module('BB1002') model.delete_module('BB1003') model.delete_module('BB1004') def test_mounted_in_both_sems(self): ''' Tests that a module that is mounted in both sems will have the mounting values '1' and '1' ''' full_mounting_plan = self.fixed_mounting_handler.full_mounting_plan test_module_code = "BB1001" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 1) assert_equal(test_module_sem_2, 1) def test_mounted_in_sem_1_only(self): ''' Tests that a module that is mounted in sem 1 only will have the mounting values '1' and '-1' ''' full_mounting_plan = self.fixed_mounting_handler.full_mounting_plan test_module_code = "BB1002" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, 1) assert_equal(test_module_sem_2, -1) def test_mounted_in_sem_2_only(self): ''' Tests that a module that is mounted in sem 2 only will have the mounting values '-1' and '1' ''' full_mounting_plan = self.fixed_mounting_handler.full_mounting_plan test_module_code = "BB1003" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, -1) assert_equal(test_module_sem_2, 1) def test_not_mounted(self): ''' Tests that a module that is not mounted in any sem will have the mounting values '-1' and '-1' ''' full_mounting_plan = self.fixed_mounting_handler.full_mounting_plan test_module_code = "BB1004" test_module_sem_1 = -2 test_module_sem_2 = -2 has_test_module = False for subplan in full_mounting_plan: if subplan[0] == test_module_code: has_test_module = True test_module_sem_1 = subplan[2] test_module_sem_2 = subplan[3] break assert_true(has_test_module) assert_equal(test_module_sem_1, -1) assert_equal(test_module_sem_2, -1) def test_all_fixed_mountings_in_same_ay(self): ''' Tests that all the fixed module mountings are in the same AY (current AY) ''' mounted_module_infos = model.get_all_fixed_mounted_modules() current_ay = self.current_ay is_same_ay = True for info in mounted_module_infos: ay = info[2][0:8] if ay != current_ay: is_same_ay = False break assert_true(is_same_ay)