Пример #1
0
    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
        '''
        test_module_code = "BB1003"
        model.delete_tenta_mounting(test_module_code, self.next_ay + ' Sem 2')

        self.module_overview_handler.load_fixed_mounting_plan(test_module_code)
        self.module_overview_handler.load_tenta_mounting_plan(test_module_code)
        tenta_mounting_plan = self.module_overview_handler.tenta_mounting_plan
        assert_true(len(tenta_mounting_plan) > 0)

        tenta_sem_2_mounting_value = tenta_mounting_plan[1][1]
        tenta_sem_2_quota = tenta_mounting_plan[1][2]
        assert_equal(tenta_sem_2_mounting_value, 0)
        assert_equal(tenta_sem_2_quota, '-')

        self.mounting_view_handler.load_mounting_info(
            test_module_code, self.current_ay + ' Sem 2')
        assert_equal(self.mounting_view_handler.mounting_status, 1)
        assert_equal(self.mounting_view_handler.quota, 40)

        self.mounting_view_handler.load_mounting_info(test_module_code,
                                                      self.next_ay + ' Sem 2')
        assert_equal(self.mounting_view_handler.mounting_status, 0)
        assert_equal(self.mounting_view_handler.quota, '-')

        model.add_tenta_mounting(test_module_code, self.next_ay + ' Sem 2', 40)
Пример #2
0
    def setUp(self):
        '''
            Add dummy modules and mountings into database
        '''
        self.test_module_CRD()
        self.module_CRD_tested = True
        model.add_module(self.test_module_code, self.test_module_name,
                         self.test_module_desc, self.test_module_mc,
                         self.test_module_status)

        self.test_fixed_mounting_CRD()
        self.fixed_mounting_CRD_tested = True

        self.test_tenta_mounting_CRD()
        self.tenta_mounting_CRD_tested = True
        model.add_tenta_mounting(self.test_module_code,
                                 self.test_module_tenta_mounting_s1,
                                 self.test_module_quota1)

        self.test_prereq_CRD()
        self.prereq_CRD_tested = True
        self.test_prereq_delete_all()
        self.prereq_delete_all_tested = True
        self.test_preclude_CRD()
        self.preclude_CRD_tested = True
        self.test_preclude_delete_all()
        self.preclude_delete_all_tested = True
        self.test_starred_CRD()
        self.starred_CRD_tested = True
Пример #3
0
    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()
Пример #4
0
    def test_tenta_mounting_CRD(self):
        '''
            Tests creating, reading and deleting of tentative mountings.
        '''
        if not self.tenta_mounting_CRD_tested:
            model.add_tenta_mounting(self.test_module_code,
                                     self.test_module_tenta_mounting_s1,
                                     self.test_module_quota1)
            model.add_tenta_mounting(self.test_module_code,
                                     self.test_module_tenta_mounting_s2,
                                     self.test_module_quota2)

            mounting_data = model.get_tenta_mounting_and_quota(
                self.test_module_code)
            assert_equal(self.test_module_mounted_count, len(mounting_data))

            mounting_s1 = mounting_data[0][0]
            mounting_s2 = mounting_data[1][0]
            quota_s1 = mounting_data[0][1]
            quota_s2 = mounting_data[1][1]

            assert_equal(self.test_module_tenta_mounting_s1, mounting_s1)
            assert_equal(self.test_module_tenta_mounting_s2, mounting_s2)
            assert_equal(self.test_module_quota1, quota_s1)
            assert_equal(self.test_module_quota2, quota_s2)

            model.delete_tenta_mounting(self.test_module_code,
                                        self.test_module_tenta_mounting_s1)
            model.delete_tenta_mounting(self.test_module_code,
                                        self.test_module_tenta_mounting_s2)

            mounting_data = model.get_tenta_mounting_and_quota(
                self.test_module_code)
            assert_true(len(mounting_data) == 0)
            return
    def test_edit_multiple_modules_mountings(self):
        '''
            Test that Edit All function can edit multiple modules' mounting(s)
        '''
        test_data = {}

        # Dummy Module 1: Mount in Sem 2
        test_mod_1_code = self.DUMMY_MODULE_CODE_1
        test_mod_1_mounting = True   #mounted
        test_mod_1_quota = 200   #quota added

        test_data[test_mod_1_code+'_isEdited'] = "True"
        test_data[test_mod_1_code+'_Sem2Mounting'] = test_mod_1_mounting   #modified to true
        test_data[test_mod_1_code+'_Sem2Quota'] = test_mod_1_quota

        # Dummy Module 3: Unmount from both sems
        test_mod_2_code = self.DUMMY_MODULE_CODE_3
        test_mod_2_mounting_1 = False   #unmounted
        test_mod_2_quota_1 = False   #quota will be false because unmounted
        test_mod_2_mounting_2 = False   #unmounted
        test_mod_2_quota_2 = False   #quota will be false because unmounted

        test_data[test_mod_2_code+'_isEdited'] = "True"
        # Because mounting is false (unchecked), no mounting value will be returned by the UI
        test_data[test_mod_2_code+'_Sem1Quota'] = test_mod_2_quota_1
        # Because mounting is false (unchecked), no mounting value will be returned by the UI
        test_data[test_mod_2_code+'_Sem2Quota'] = test_mod_2_quota_2

        self.edit_all_handler.POST(test_data)

        mounting = model.get_mounting_of_target_tenta_ay_sem(test_mod_1_code,
                                                             self.next_ay+" Sem 2")
        quota = model.get_quota_of_target_tenta_ay_sem(test_mod_1_code,
                                                       self.next_ay+" Sem 2")
        assert_equal(mounting, test_mod_1_mounting)
        assert_equal(quota, test_mod_1_quota)

        mounting = model.get_mounting_of_target_tenta_ay_sem(test_mod_2_code,
                                                             self.next_ay+" Sem 1")
        quota = model.get_quota_of_target_tenta_ay_sem(test_mod_2_code,
                                                       self.next_ay+" Sem 1")
        assert_equal(mounting, test_mod_2_mounting_1)
        assert_equal(quota, test_mod_2_quota_1)

        mounting = model.get_mounting_of_target_tenta_ay_sem(test_mod_2_code,
                                                             self.next_ay+" Sem 2")
        quota = model.get_quota_of_target_tenta_ay_sem(test_mod_2_code,
                                                       self.next_ay+" Sem 2")
        assert_equal(mounting, test_mod_2_mounting_2)
        assert_equal(quota, test_mod_2_quota_2)

        model.delete_tenta_mounting(test_mod_1_code, self.next_ay+" Sem 2")
        model.add_tenta_mounting(test_mod_2_code, self.next_ay+" Sem 1", self.DUMMY_QUOTA_3)
        model.add_tenta_mounting(test_mod_2_code, self.next_ay+" Sem 2", self.DUMMY_QUOTA_0)
Пример #6
0
    def setUp(self):
        '''
            Add dummy modules and mountings into database
        '''
        self.module_overview_handler = ViewMod()
        self.mounting_view_handler = IndividualModule()
        self.current_ay = model.get_current_ay()
        self.next_ay = self.get_next_ay(self.current_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')

        # 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)

        # 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)
Пример #7
0
 def test_add_mounting_with_repeat_code_and_ay_sem(self):
     '''
         Tests that a module cannot have more than one mounting in the same AY/Sem
     '''
     outcome = model.add_tenta_mounting(self.test_module_code,
                                        self.test_module_tenta_mounting_s1,
                                        123)
     assert_false(outcome)
    def test_edit_single_module_mounting(self):
        '''
            Test that Edit All function can edit a single module's mounting
        '''
        test_module_code = self.DUMMY_MODULE_CODE_1
        test_mounting = False   #unmounted
        test_quota = False   #quota will be false because unmounted

        # Unmount from Sem 1
        test_data = {}
        test_data[test_module_code+'_isEdited'] = "True"
        # Because mounting is false (unchecked), no mounting value will be returned by the UI
        test_data[test_module_code+'_Sem1Quota'] = test_quota

        self.edit_all_handler.POST(test_data)

        mounting = model.get_mounting_of_target_tenta_ay_sem(test_module_code,
                                                             self.next_ay+" Sem 1")
        quota = model.get_quota_of_target_tenta_ay_sem(test_module_code,
                                                       self.next_ay+" Sem 1")
        assert_equal(mounting, test_mounting)
        assert_equal(quota, test_quota)

        model.add_tenta_mounting(test_module_code, self.next_ay+" Sem 1", self.DUMMY_QUOTA_1)

        # Mount in Sem 2
        test_module_code = self.DUMMY_MODULE_CODE_2
        test_mounting = True
        test_quota = 200

        test_data = {}
        test_data[test_module_code+'_isEdited'] = "True"
        test_data[test_module_code+'_Sem2Mounting'] = True   #modified to true
        test_data[test_module_code+'_Sem2Quota'] = test_quota  #modified

        self.edit_all_handler.POST(test_data)

        mounting = model.get_mounting_of_target_tenta_ay_sem(test_module_code,
                                                             self.next_ay+" Sem 2")
        quota = model.get_quota_of_target_tenta_ay_sem(test_module_code,
                                                       self.next_ay+" Sem 2")
        assert_equal(mounting, test_mounting)
        assert_equal(quota, test_quota)

        model.delete_tenta_mounting(test_module_code, self.next_ay+" Sem 2")
Пример #9
0
    def POST(self):
        '''
            Handles the submission of the 'Edit Specific Module Info' page
        '''
        input_data = model.validate_input(web.input(), ["code", "aysem"],
                                          is_future=True, show_404=False)

        module_code = None
        ay_sem = None
        try:
            module_code = input_data.code
            ay_sem = input_data.aysem
            mounting_status = input_data.mountingStatus
        except AttributeError:
            return Outcome().POST("edit_mounting", False, module_code, ay_sem)

        try:
            quota = input_data.quota
            if quota == "":
                quota = None
        except AttributeError:
            quota = None

        outcome = None
        # If quota is being set by the user, it should not fall below 0.
        # Otherwise, if the user is not interested in leaving a value for
        # the quota, leaving it blank (none) is acceptable.
        if quota is not None:
            try:
                quota = int(quota)
                if quota < 0 or quota > 999:
                    outcome = False
            except ValueError:  # quota is not None or int
                outcome = False

        if outcome is not False:
            module_info = model.get_module(module_code)
            if module_info is None:
                outcome = False
            elif ay_sem not in self.list_of_future_ay_sems:
                outcome = False
            else:
                if mounting_status == "Mounted":
                    outcome = None
                    old_mounting_status = model.get_mounting_of_target_tenta_ay_sem(module_code,
                                                                                    ay_sem)
                    if old_mounting_status is True:
                        outcome = model.update_quota(module_code, ay_sem, quota)
                    else:
                        outcome = model.add_tenta_mounting(module_code, ay_sem, quota)
                elif mounting_status == "Not Mounted":
                    outcome = model.delete_tenta_mounting(module_code, ay_sem)
                else:
                    outcome = False

        return Outcome().POST("edit_mounting", outcome, module_code, ay_sem)
Пример #10
0
    def POST(self, *test_data):
        '''
            Handles the restoration of module info
        '''
        if test_data:  # for testing purposes
            input_data = test_data[0]
        else:
            input_data = model.validate_input(web.input(),
                                              ["code", "restore_type"])

        module_code = input_data.code
        restore_type = input_data.restoreType

        if restore_type.lower() == "quota":
            model.validate_input(input_data, ["aysem"])
            ay_sem = input_data.aysem

            quota = input_data.quota
            if quota == "":
                quota = None

            outcome = model.update_quota(module_code, ay_sem, quota)

            if not test_data:
                return Outcome().POST("restore_module", outcome, module_code)

        elif restore_type.lower() == "mounting":
            model.validate_input(input_data, ["aysem"])
            target_ay_sem = input_data.aysem
            mounting_change = int(input_data.mountingChange)

            outcome = None
            if mounting_change == 1:  # Is mounted, so should revert to unmounted
                outcome = model.delete_tenta_mounting(module_code,
                                                      target_ay_sem)
            elif mounting_change == 0:  # Is unmounted, so should revert to mounted
                current_ay_sem = input_data.currentAySem
                quota = model.get_quota_of_target_fixed_ay_sem(
                    module_code, current_ay_sem)
                outcome = model.add_tenta_mounting(module_code, target_ay_sem,
                                                   quota)

            if not test_data:
                return Outcome().POST("restore_module", outcome, module_code)

        elif restore_type.lower() == "moduledetails":
            original_module_details = model.get_original_module_info(
                module_code)
            model.remove_original_module_info(module_code)
            outcome = model.update_module(module_code,
                                          original_module_details[1],
                                          original_module_details[2],
                                          original_module_details[3])

            if not test_data:
                return Outcome().POST("restore_module", outcome, module_code)
Пример #11
0
    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'
        '''
        test_module_code = "BB1001"
        model.delete_tenta_mounting(test_module_code, self.next_ay + ' Sem 1')
        model.delete_tenta_mounting(test_module_code, self.next_ay + ' Sem 2')

        self.module_overview_handler.load_fixed_mounting_plan(test_module_code)
        self.module_overview_handler.load_tenta_mounting_plan(test_module_code)
        tenta_mounting_plan = self.module_overview_handler.tenta_mounting_plan
        assert_true(len(tenta_mounting_plan) > 0)

        tenta_sem_1_mounting_value = tenta_mounting_plan[0][1]
        tenta_sem_1_quota = tenta_mounting_plan[0][2]
        tenta_sem_2_mounting_value = tenta_mounting_plan[1][1]
        tenta_sem_2_quota = tenta_mounting_plan[1][2]
        assert_equal(tenta_sem_1_mounting_value, 0)
        assert_equal(tenta_sem_1_quota, '-')
        assert_equal(tenta_sem_2_mounting_value, 0)
        assert_equal(tenta_sem_2_quota, '-')

        self.mounting_view_handler.load_mounting_info(
            test_module_code, self.current_ay + ' Sem 1')
        assert_equal(self.mounting_view_handler.mounting_status, 1)
        assert_equal(self.mounting_view_handler.quota, 10)
        self.mounting_view_handler.load_mounting_info(
            test_module_code, self.current_ay + ' Sem 2')
        assert_equal(self.mounting_view_handler.mounting_status, 1)
        assert_equal(self.mounting_view_handler.quota, 20)

        self.mounting_view_handler.load_mounting_info(test_module_code,
                                                      self.next_ay + ' Sem 1')
        assert_equal(self.mounting_view_handler.mounting_status, 0)
        assert_equal(self.mounting_view_handler.quota, '-')
        self.mounting_view_handler.load_mounting_info(test_module_code,
                                                      self.next_ay + ' Sem 2')
        assert_equal(self.mounting_view_handler.mounting_status, 0)
        assert_equal(self.mounting_view_handler.quota, '-')

        model.add_tenta_mounting(test_module_code, self.next_ay + ' Sem 1', 10)
        model.add_tenta_mounting(test_module_code, self.next_ay + ' Sem 2', 20)
Пример #12
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 setUp(self):
        '''
            Add dummy modules and mountings into database
        '''
        # Dummy modules
        self.DUMMY_MODULE_CODE_1 = 'BB1001'
        self.DUMMY_MODULE_CODE_2 = 'BB1002'
        self.DUMMY_MODULE_CODE_3 = 'BB1003'
        model.add_module(self.DUMMY_MODULE_CODE_1, 'Dummy Module 1',
                         "Dummy Module", 1, 'Active')
        model.add_module(self.DUMMY_MODULE_CODE_2, 'Dummy Module 2',
                         "Dummy Module", 2, 'Active')
        model.add_module(self.DUMMY_MODULE_CODE_3, 'Dummy Module 3',
                         "Dummy Module", 3, 'Active')

        # Dummy mountings
        self.DUMMY_QUOTA_0 = None
        self.DUMMY_QUOTA_1 = 10
        self.DUMMY_QUOTA_2 = 20
        self.DUMMY_QUOTA_3 = 30
        model.add_fixed_mounting(self.DUMMY_MODULE_CODE_1,
                                 self.current_ay+' Sem 1', self.DUMMY_QUOTA_1)
        model.add_tenta_mounting(self.DUMMY_MODULE_CODE_1,
                                 self.next_ay+' Sem 1', self.DUMMY_QUOTA_1)
        model.add_fixed_mounting(self.DUMMY_MODULE_CODE_2,
                                 self.current_ay+' Sem 2', self.DUMMY_QUOTA_2)
        model.add_tenta_mounting(self.DUMMY_MODULE_CODE_2,
                                 self.next_ay+' Sem 2', self.DUMMY_QUOTA_2)
        model.add_fixed_mounting(self.DUMMY_MODULE_CODE_3,
                                 self.current_ay+' Sem 1', self.DUMMY_QUOTA_3)
        model.add_tenta_mounting(self.DUMMY_MODULE_CODE_3,
                                 self.next_ay+' Sem 1', self.DUMMY_QUOTA_3)
        model.add_fixed_mounting(self.DUMMY_MODULE_CODE_3,
                                 self.current_ay+' Sem 2', self.DUMMY_QUOTA_0)
        model.add_tenta_mounting(self.DUMMY_MODULE_CODE_3,
                                 self.next_ay+' Sem 2', self.DUMMY_QUOTA_0)
Пример #14
0
    def POST(self, *test_data):
        '''
            Handles the editing operations for all mountings and quotas
        '''
        if test_data:
            input_data = test_data[0]
        else:
            input_data = web.input()
        all_modules = model.get_all_modules()
        target_ay = model.get_next_ay(model.get_current_ay())

        for module in all_modules:
            module_code = module[0]
            try:
                is_module_edited = input_data[module_code+"_isEdited"]
            except KeyError:
                is_module_edited = "False"

            if is_module_edited == "True":
                try:
                    sem1_mounting = input_data[module_code+"_Sem1Mounting"]
                    sem1_mounting = True
                except KeyError:
                    sem1_mounting = False
                try:
                    sem2_mounting = input_data[module_code+"_Sem2Mounting"]
                    sem2_mounting = True
                except KeyError:
                    sem2_mounting = False

                try:
                    sem1_quota = input_data[module_code+"_Sem1Quota"]
                    if sem1_quota == "":  # quota = '?'
                        sem1_quota = None
                except KeyError:  # quota = '-'
                    sem1_quota = None
                if sem1_quota is not None:
                    try:
                        sem1_quota = int(sem1_quota)
                        if sem1_quota < 0 or sem1_quota > 999:
                            if test_data:
                                return False
                            else:
                                return Outcome().POST("edit_all_mountings_and_quotas", False, None)
                    except ValueError:  # quota is not an integer
                        if test_data:
                            return False
                        else:
                            return Outcome().POST("edit_all_mountings_and_quotas", False, None)

                try:
                    sem2_quota = input_data[module_code+"_Sem2Quota"]
                    if sem2_quota == "":  # quota = '?'
                        sem2_quota = None
                except KeyError:  # quota = '-'
                    sem2_quota = None
                if sem2_quota is not None:
                    try:
                        sem2_quota = int(sem2_quota)
                        if sem2_quota < 0 or sem2_quota > 999:
                            if test_data:
                                return False
                            else:
                                return Outcome().POST("edit_all_mountings_and_quotas", False, None)
                    except ValueError:  # quota is not an integer
                        if test_data:
                            return False
                        else:
                            return Outcome().POST("edit_all_mountings_and_quotas", False, None)

                target_aysem = target_ay+" Sem 1"
                outcome = None
                if sem1_mounting is True:
                    old_mounting = model.get_mounting_of_target_tenta_ay_sem(module_code,
                                                                             target_aysem)
                    if old_mounting is True:
                        outcome = model.update_quota(module_code,
                                                     target_aysem, sem1_quota)
                    else:
                        outcome = model.add_tenta_mounting(module_code,
                                                           target_aysem, sem1_quota)
                else:
                    outcome = model.delete_tenta_mounting(module_code, target_aysem)
                if outcome is False:
                    return Outcome().POST("edit_all_mountings_and_quotas", False, None)

                target_aysem = target_ay+" Sem 2"
                outcome = None
                if sem2_mounting is True:
                    old_mounting = model.get_mounting_of_target_tenta_ay_sem(module_code,
                                                                             target_aysem)
                    if old_mounting is True:
                        outcome = model.update_quota(module_code,
                                                     target_aysem, sem2_quota)
                    else:
                        outcome = model.add_tenta_mounting(module_code,
                                                           target_aysem, sem2_quota)
                else:
                    outcome = model.delete_tenta_mounting(module_code, target_aysem)
                if outcome is False:
                    return Outcome().POST("edit_all_mountings_and_quotas", False, None)

        if not test_data:
            return Outcome().POST("edit_all_mountings_and_quotas", True, None)
Пример #15
0
    def setUp(self):
        '''
            Add dummy modules, mountings and student planners into database
        '''

        # Dummy modules
        model.add_module('PT1001', 'Dummy Module 1',
                         "Dummy Module 1", 1, 'Active')
        model.add_module('PT1002', 'Dummy Module 2',
                         "Dummy Module 2", 2, 'Active')
        model.add_module('PT1003', 'Dummy Module 3',
                         "Dummy Module 3", 3, 'Active')
        model.add_module('PT1004', 'Dummy Module 4',
                         "Dummy Module 4", 4, 'Active')
        model.add_module('PT1005', 'Dummy Module 5',
                         "Dummy Module 5", 5, 'Active')

        model.add_fixed_mounting('PT1001', self.current_ay+' Sem 1', 10)
        model.add_fixed_mounting('PT1001', self.current_ay+' Sem 2', 15)
        model.add_fixed_mounting('PT1002', self.current_ay+' Sem 2', 20)

        model.add_tenta_mounting('PT1001', self.next_ay+' Sem 1', 10)
        model.add_tenta_mounting('PT1002', self.next_ay+' Sem 2', 20)
        model.add_tenta_mounting('PT1003', self.next_ay+' Sem 1', 30)
        model.add_tenta_mounting('PT1003', self.next_ay+' Sem 2', 35)
        model.add_tenta_mounting('PT1004', self.next_ay+' Sem 2', 40)
        model.add_tenta_mounting('PT1005', self.next_ay+' Sem 1', 50)

        model.add_student_plan('D1000000A', True, 'PT1001', self.current_ay+' Sem 1')
        model.add_student_plan('D1000000A', True, 'PT1002', self.current_ay+' Sem 2')
        model.add_student_plan('D2000000A', True, 'PT1001', self.current_ay+' Sem 1')
        model.add_student_plan('D2000000A', False, 'PT1002', self.current_ay+' Sem 2')
        model.add_student_plan('D1000000A', False, 'PT1003', self.next_ay+' Sem 1')
        model.add_student_plan('D3000000A', False, 'PT1001', self.current_ay+' Sem 1')
        model.add_student_plan('D3000000A', False, 'PT1004', self.next_ay+' Sem 2')

        model.add_student_plan('D5000000A', True, 'PT1001', self.current_ay+' Sem 1')
        model.add_student_plan('D5000001A', True, 'PT1001', self.current_ay+' Sem 1')
        model.add_student_plan('D5000002A', True, 'PT1001', self.current_ay+' Sem 2')
        model.add_student_plan('D5000000A', False, 'PT1005', self.next_ay+' Sem 1')
        model.add_student_plan('D5000001A', False, 'PT1005', self.next_ay+' Sem 1')
        model.add_student_plan('D5000002A', False, 'PT1005', self.next_ay+' Sem 1')
        model.add_student_plan('D5000003A', False, 'PT1005', self.next_ay+' Sem 1')
        model.add_student_plan('D5000004A', False, 'PT1005', self.next_ay+' Sem 1')
    def setUp(self):
        '''
            Add dummy modules and mountings into database
        '''
        # Dummy modules
        model.add_module('BB1001', 'Dummy Module 1',
                         "This module's quota is NOT modified", 1, 'Active')
        model.add_module('BB1002', 'Dummy Module 2',
                         "This module's quota for sem 1 is modified", 2, 'Active')
        model.add_module('BB1003', 'Dummy Module 3',
                         "This module's quota for sem 2 is modified", 3, 'Active')
        model.add_module('BB1004', 'Dummy Module 4',
                         "This module's quota for sem 1 has become specified", 4, 'Active')
        model.add_module('BB1005', 'Dummy Module 5',
                         "This module's quota for sem 2 has become unspecified", 5, 'Active')
        model.add_module('BB1006', 'Dummy Module 6',
                         "This module's quota for both sem 1 & 2 have been modified",
                         6, 'Active')

        model.add_module('BB2001', 'Dummy Module 1',
                         "This module is unmounted from sem 1", 1, 'Active')
        model.add_module('BB2002', 'Dummy Module 2',
                         "This module is remounted in sem 2", 2, 'Active')
        model.add_module('BB2003', 'Dummy Module 3',
                         "This module is changed from mounted in sem 1 to sem 2", 3, 'Active')
        model.add_module('BB2004', 'Dummy Module 4',
                         "This module's mounting is modified but quota is not modified",
                         4, 'Active')

        model.add_module('BB3001', 'Dummy Module 1',
                         "This module's quota is modified and will be restored", 1, 'Active')
        model.add_module('BB3002', 'Dummy Module 2',
                         "This module's quota has been specified and will be restored" +\
                         "to unspecified", 2, 'Active')
        model.add_module('BB3003', 'Dummy Module 3',
                         "This module's has been mounted and will be restored to unmounted",
                         3, 'Active')
        model.add_module('BB3004', 'Dummy Module 4',
                         "This module's has been unmounted and will be restored to mounted",
                         4, 'Active')
        model.add_module('BB3005', 'Dummy Module 5',
                         "This module's name will be restored", 5, 'Active')
        model.add_module('BB3006', 'Dummy Module 6',
                         "This module's name, description and MC will be restored", 6,
                         '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', 10)
        model.add_fixed_mounting('BB1002', self.current_ay+' Sem 1', 20)
        model.add_fixed_mounting('BB1002', self.current_ay+' Sem 2', 20)
        model.add_fixed_mounting('BB1003', self.current_ay+' Sem 1', 30)
        model.add_fixed_mounting('BB1003', self.current_ay+' Sem 2', 30)
        model.add_fixed_mounting('BB1004', self.current_ay+' Sem 1', None)
        model.add_fixed_mounting('BB1004', self.current_ay+' Sem 2', None)
        model.add_fixed_mounting('BB1005', self.current_ay+' Sem 1', 50)
        model.add_fixed_mounting('BB1005', self.current_ay+' Sem 2', 50)
        model.add_fixed_mounting('BB1006', self.current_ay+' Sem 1', 60)
        model.add_fixed_mounting('BB1006', self.current_ay+' Sem 2', 60)

        model.add_fixed_mounting('BB2001', self.current_ay+' Sem 1', 10)
        model.add_fixed_mounting('BB2001', self.current_ay+' Sem 2', 10)
        model.add_fixed_mounting('BB2002', self.current_ay+' Sem 1', 20)
        model.add_fixed_mounting('BB2003', self.current_ay+' Sem 1', 30)
        model.add_fixed_mounting('BB2004', self.current_ay+' Sem 1', None)

        model.add_fixed_mounting('BB3001', self.current_ay+' Sem 1', 10)
        model.add_fixed_mounting('BB3002', self.current_ay+' Sem 1', None)
        model.add_fixed_mounting('BB3004', self.current_ay+' Sem 2', 40)

        # Dummy tentative mountings
        model.add_tenta_mounting('BB1001', self.next_ay+' Sem 1', 10)
        model.add_tenta_mounting('BB1001', self.next_ay+' Sem 2', 10)
        model.add_tenta_mounting('BB1002', self.next_ay+' Sem 1', 999)
        model.add_tenta_mounting('BB1002', self.next_ay+' Sem 2', 20)
        model.add_tenta_mounting('BB1003', self.next_ay+' Sem 1', 30)
        model.add_tenta_mounting('BB1003', self.next_ay+' Sem 2', 999)
        model.add_tenta_mounting('BB1004', self.next_ay+' Sem 1', 999)
        model.add_tenta_mounting('BB1004', self.next_ay+' Sem 2', None)
        model.add_tenta_mounting('BB1005', self.next_ay+' Sem 1', 50)
        model.add_tenta_mounting('BB1005', self.next_ay+' Sem 2', None)
        model.add_tenta_mounting('BB1006', self.next_ay+' Sem 1', 999)
        model.add_tenta_mounting('BB1006', self.next_ay+' Sem 2', None)

        model.add_tenta_mounting('BB2001', self.next_ay+' Sem 2', 10)
        model.add_tenta_mounting('BB2002', self.next_ay+' Sem 1', 20)
        model.add_tenta_mounting('BB2002', self.next_ay+' Sem 2', 20)
        model.add_tenta_mounting('BB2003', self.next_ay+' Sem 2', 30)
        model.add_tenta_mounting('BB2004', self.next_ay+' Sem 1', None)
        model.add_tenta_mounting('BB2004', self.next_ay+' Sem 2', None)

        model.add_tenta_mounting('BB3001', self.next_ay+' Sem 1', 999)
        model.add_tenta_mounting('BB3002', self.next_ay+' Sem 1', 999)
        model.add_tenta_mounting('BB3003', self.next_ay+' Sem 2', 999)

        # Dummy module backup
        model.store_original_module_info('BB3005', 'Original Module Name',
                                         "This module's name will be restored", 5)
        model.store_original_module_info('BB3006', 'Original Module Name',
                                         "Original Module Description", 0)