def test_list_students_take_module_two_focus(self):
        '''
            Tests querying the list of students who plan
            to take a certain mod in a specified semester,
            where these students have exactly 2 focus areas.
        '''

        # Add some modules and dummy students
        model.add_student('dummyYr1A', 1)
        model.add_student_focus_area('dummyYr1A', 'Database Systems',
                                     'Computer Graphics and Games')
        model.add_student_plan('dummyYr1A', True, 'CS1010', 'AY 16/17 Sem 1')

        list_of_students_take_mod = \
            model.get_list_students_take_module('CS1010', 'AY 16/17 Sem 1')

        required_entry = [
            'dummyYr1A', 1, 'Database Systems', 'Computer Graphics and Games'
        ]

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_student_focus_area('dummyYr1A')
        model.delete_student('dummyYr1A')

        assert required_entry in list_of_students_take_mod
Esempio n. 2
0
    def test_query_module_taken_together_specified_mod_specified_aysem(self):
        '''
            Tests querying the list of modules taken together
            with specified module in the specified semester
        '''

        # Add some dummy students and modules
        model.add_student('dummyYr1A', 1)
        model.add_module('AAA1111', 'Dummy 1', 'Description', 4, 'Active')
        model.add_module('AAA1112', 'Dummy 2', 'Description', 4, 'Active')
        model.add_student_plan('dummyYr1A', True, 'AAA1111', 'AY 17/18 Sem 2')
        model.add_student_plan('dummyYr1A', True, 'AAA1112', 'AY 17/18 Sem 2')

        list_of_mod_taken_together = \
            model.get_mod_taken_together_with_mod_and_aysem('AAA1111', 'AY 17/18 Sem 2')

        required_list = [('AAA1111', 'Dummy 1', 'AAA1112', 'Dummy 2', 1)]

        assert_equal(len(list_of_mod_taken_together), len(required_list))
        assert_equal(sorted(list_of_mod_taken_together), sorted(required_list))
        assert_true(
            self.is_count_in_non_ascending_order(list_of_mod_taken_together))

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_module('AAA1111')
        model.delete_module('AAA1112')
        model.delete_student('dummyYr1A')
Esempio n. 3
0
    def test_query_module_before_internship(self):
        '''
            Tests querying the list of modules taken before internship,
            in AY/Sem with people doing internship in.
        '''
        # Add some modules and dummy students
        required_dummy = ('AAA1111', 'Dummy for Intern', 1)
        model.add_student('dummyYr1A', 1)
        model.add_module('AAA1111', 'Dummy for Intern', 'Description', 4,
                         'Active')
        model.add_student_plan('dummyYr1A', True, 'AAA1111', 'AY 16/17 Sem 2')
        model.add_student_plan('dummyYr1A', True, self.INTERN_MOD,
                               self.INTERN_SEM)

        # Get list of modules taken before internship
        list_of_modules_before_internship = model.get_mod_before_intern(
            self.INTERN_SEM)

        assert required_dummy in list_of_modules_before_internship

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_module('AAA1111')
        model.delete_student('dummyYr1A')

        # Test that required dummy no longer in list
        list_of_modules_before_internship = model.get_mod_before_intern(
            self.INTERN_SEM)

        assert required_dummy not in list_of_modules_before_internship
Esempio n. 4
0
    def test_query_module_taken_together_entire_list(self):
        '''
            Tests querying the list of modules taken together
            in the same semester
        '''
        # Add some dummy students and modules
        model.add_student('dummyYr1A', 1)
        model.add_module('AAA1111', 'Dummy 1', 'Description', 4, 'Active')
        model.add_module('AAA1112', 'Dummy 2', 'Description', 4, 'Active')
        model.add_module('AAA1113', 'Dummy 3', 'Description', 4, 'Active')
        model.add_student_plan('dummyYr1A', True, 'AAA1111', 'AY 17/18 Sem 1')
        model.add_student_plan('dummyYr1A', True, 'AAA1112', 'AY 17/18 Sem 1')
        model.add_student_plan('dummyYr1A', True, 'AAA1112', 'AY 17/18 Sem 2')
        model.add_student_plan('dummyYr1A', True, 'AAA1113', 'AY 17/18 Sem 2')

        list_of_mod_taken_together = \
            model.get_all_mods_taken_together()

        assert_true(
            self.is_count_in_non_ascending_order(list_of_mod_taken_together))

        assert ('AAA1111', 'Dummy 1', 'AAA1112', 'Dummy 2', 'AY 17/18 Sem 1',
                1) in list_of_mod_taken_together
        assert ('AAA1112', 'Dummy 2', 'AAA1113', 'Dummy 3', 'AY 17/18 Sem 2',
                1) in list_of_mod_taken_together

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_module('AAA1111')
        model.delete_module('AAA1112')
        model.delete_module('AAA1113')
        model.delete_student('dummyYr1A')
    def test_query_oversubscribed_modules(self):
        '''
            Tests querying the list of oversubscribed modules.
        '''
        # To simulate an oversubscribed module, add a module with 0 quota,
        # then add a student who wants to take the module.
        model.add_student('dummyYr1A', 1)
        model.add_module('AAA1111', 'Test Module', 'Description', 4, 'Active')
        model.add_student_plan('dummyYr1A', False, 'AAA1111', 'AY 17/18 Sem 1')

        list_of_oversub_mod = model.get_oversub_mod()
        oversubscribed_module = ('AAA1111', 'Test Module', 'AY 17/18 Sem 1',
                                 '?', 1)

        # Clean up the database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_module("AAA1111")
        model.delete_student('dummyYr1A')

        # Test for presence of oversubscribed module
        assert oversubscribed_module in list_of_oversub_mod
Esempio n. 6
0
    def test_query_module_before_internship_with_mod_after_internship(self):
        '''
            Tests querying the list of modules taken before internship,
            in AY/Sem with people doing internship in, and
            with some modules taken after or during aysem of internship
        '''
        # Get list of modules before internship
        list_of_modules_before_internship = model.get_mod_before_intern(
            self.INTERN_SEM)

        # Add some dummy students and plans. They should not affect the list
        model.add_student('dummyYr1A', 1)
        model.add_module('AAA1111', 'Dummy with Intern', 'Description', 4,
                         'Active')
        model.add_module('AAA1112', 'Dummy after Intern', 'Description', 4,
                         'Active')
        model.add_student_plan('dummyYr1A', True, 'AAA1111', self.INTERN_SEM)
        model.add_student_plan('dummyYr1A', True, self.INTERN_MOD,
                               self.INTERN_SEM)
        model.add_student_plan('dummyYr1A', True, 'AAA1112', 'AY 17/18 Sem 2')

        # Get new list of modules before internship. It should remain unchanged.
        new_list_of_modules_before_internship = model.get_mod_before_intern(
            self.INTERN_SEM)

        assert_equal(len(list_of_modules_before_internship),
                     len(new_list_of_modules_before_internship))
        assert_equal(sorted(list_of_modules_before_internship),
                     sorted(new_list_of_modules_before_internship))

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_module('AAA1111')
        model.delete_module('AAA1112')
        model.delete_student('dummyYr1A')
Esempio n. 7
0
    def test_query_module_taken_together_specified_mod(self):
        '''
            Tests querying the list of modules taken together
            with specified module in the same semester
        '''
        # Add some dummy students and modules
        model.add_student('dummyYr1A', 1)
        model.add_module('AAA1111', 'Dummy 1', 'Description', 4, 'Active')
        model.add_module('AAA1112', 'Dummy 2', 'Description', 4, 'Active')
        model.add_student_plan('dummyYr1A', True, 'AAA1111', 'AY 17/18 Sem 2')
        model.add_student_plan('dummyYr1A', True, 'AAA1112', 'AY 17/18 Sem 2')

        list_of_mod_taken_together = \
            model.get_mod_taken_together_with('AAA1111')

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_module('AAA1111')
        model.delete_module('AAA1112')
        model.delete_student('dummyYr1A')

        assert ('AAA1111', 'Dummy 1', 'AAA1112', 'Dummy 2', 'AY 17/18 Sem 2',
                1) in list_of_mod_taken_together
    def test_query_oversubscribed_modules_reworked(self):
        '''
            Tests querying the list of oversubscribed modules.
            (This test uses the reworked function)
        '''
        # To simulate an oversubscribed module, add a module with 0 quota,
        # then add a student who wants to take the module.
        oversub_handler = OversubModule()

        model.add_student('dummyYr1A', 1)
        model.add_module('AAA1111', 'Test Module', 'Description', 4, 'Active')
        model.add_student_plan('dummyYr1A', False, 'AAA1111', 'AY 17/18 Sem 1')

        list_of_oversub_mod = oversub_handler.GET("AY 17/18 Sem 1")
        oversubscribed_module = ('AAA1111', 'Test Module', 'AY 17/18 Sem 1',
                                 '-', 1, 1)

        # Clean up the database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_module("AAA1111")
        model.delete_student('dummyYr1A')

        # Test for presence of oversubscribed module
        assert oversubscribed_module in list_of_oversub_mod
    def test_query_num_students_in_year_of_study_for_target_module(self):
        '''
            Tests querying number of students for each year of study for a target module
        '''
        test_module_code = "CS1010"
        test_ay_sem_1 = "AY 16/17 Sem 1"

        # Add some students and plans
        model.add_student('dummyYr1A', 1)
        model.add_student('dummyYr1B', 1)
        model.add_student('dummyYr2A', 2)
        model.add_student_plan('dummyYr2A', True, 'CS1010', test_ay_sem_1)

        # Get current count of students taking CS1010
        self.module_view_in_ay_sem_handler.load_focus_areas()
        self.module_view_in_ay_sem_handler.load_student_enrollments(
            test_module_code, test_ay_sem_1)
        student_year_counts = self.module_view_in_ay_sem_handler.student_year_counts

        # Add and remove some plans
        model.add_student_plan('dummyYr1A', True, 'CS1010', test_ay_sem_1)
        model.add_student_plan('dummyYr1B', True, 'CS1010', test_ay_sem_1)
        model.delete_student_plan('dummyYr2A', 'CS1010', test_ay_sem_1)

        # Get new count of students taking CS1010
        self.module_view_in_ay_sem_handler.load_focus_areas()
        self.module_view_in_ay_sem_handler.load_student_enrollments(
            test_module_code, test_ay_sem_1)
        new_student_year_counts = self.module_view_in_ay_sem_handler.student_year_counts

        # Check if difference is as expected
        assert_equal(new_student_year_counts[0] - student_year_counts[0], 2)
        assert_equal(new_student_year_counts[1] - student_year_counts[1], -1)
        assert_equal(new_student_year_counts[2] - student_year_counts[2], 0)
        assert_equal(new_student_year_counts[3] - student_year_counts[3], 0)
        assert_equal(new_student_year_counts[4] - student_year_counts[4], 0)
        assert_equal(new_student_year_counts[5] - student_year_counts[5], 0)

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_all_plans_of_student('dummyYr1B')
        model.delete_all_plans_of_student('dummyYr2A')
        model.delete_student('dummyYr1A')
        model.delete_student('dummyYr1B')
        model.delete_student('dummyYr2A')
Esempio n. 10
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 test_query_num_students_in_focus_area_for_target_module(self):
        '''
            Tests querying number of students for each focus area for a target module
        '''
        test_module_code = "CS1010"
        test_ay_sem_1 = "AY 16/17 Sem 1"

        # Add some students with focus areas and plans
        model.add_student('dummyYr1A', 1)
        model.add_student('dummyYr1B', 1)
        model.add_student('dummyYr2A', 2)
        model.add_student_focus_area('dummyYr1A', 'Artificial Intelligence',
                                     None)
        model.add_student_focus_area('dummyYr1B', 'Database Systems',
                                     'Algorithms & Theory')
        model.add_student_focus_area('dummyYr2A', 'Algorithms & Theory', None)
        model.add_student_plan('dummyYr1A', True, 'CS1010', test_ay_sem_1)

        # Get current focus count of students taking CS1010
        self.module_view_in_ay_sem_handler.load_focus_areas()
        self.module_view_in_ay_sem_handler.load_student_enrollments(
            test_module_code, test_ay_sem_1)
        focus_area_counts = self.module_view_in_ay_sem_handler.focus_area_counts

        # Add and remove some plans
        model.add_student_plan('dummyYr1B', True, 'CS1010', test_ay_sem_1)
        model.add_student_plan('dummyYr2A', True, 'CS1010', test_ay_sem_1)
        model.delete_student_plan('dummyYr1A', 'CS1010', test_ay_sem_1)

        # Get new count of students taking CS1010
        self.module_view_in_ay_sem_handler.load_focus_areas()
        self.module_view_in_ay_sem_handler.load_student_enrollments(
            test_module_code, test_ay_sem_1)
        new_focus_area_counts = self.module_view_in_ay_sem_handler.focus_area_counts

        # Check if difference is as expected
        assert_equal(new_focus_area_counts["Nil"] - focus_area_counts["Nil"],
                     0)
        assert_equal(new_focus_area_counts["AT"] - focus_area_counts["AT"], 2)
        assert_equal(new_focus_area_counts["AI"] - focus_area_counts["AI"], -1)
        assert_equal(new_focus_area_counts["CGaG"] - focus_area_counts["CGaG"],
                     0)
        assert_equal(new_focus_area_counts["CS"] - focus_area_counts["CS"], 0)
        assert_equal(new_focus_area_counts["DS"] - focus_area_counts["DS"], 1)
        assert_equal(new_focus_area_counts["MIR"] - focus_area_counts["MIR"],
                     0)
        assert_equal(new_focus_area_counts["NaDS"] - focus_area_counts["NaDS"],
                     0)
        assert_equal(new_focus_area_counts["PC"] - focus_area_counts["PC"], 0)
        assert_equal(new_focus_area_counts["PL"] - focus_area_counts["PL"], 0)
        assert_equal(new_focus_area_counts["SE"] - focus_area_counts["SE"], 0)

        # Clean up database
        model.delete_all_plans_of_student('dummyYr1A')
        model.delete_all_plans_of_student('dummyYr1B')
        model.delete_all_plans_of_student('dummyYr2A')
        model.delete_student_focus_area('dummyYr1A')
        model.delete_student_focus_area('dummyYr1B')
        model.delete_student_focus_area('dummyYr2A')
        model.delete_student('dummyYr1A')
        model.delete_student('dummyYr1B')
        model.delete_student('dummyYr2A')