Ejemplo n.º 1
0
    def test_has_summer_quarter_section(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2012
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            self.assertTrue(has_summer_quarter_section(schedule))

            term = Term()
            term.year = 2012
            term.quarter = "autumn"
            schedule = _get_schedule(regid, term)
            self.assertFalse(has_summer_quarter_section(schedule))
Ejemplo n.º 2
0
    def test_get_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2012
        term.quarter = "summer"
        schedule = _get_schedule(regid, term)

        buildings = get_buildings_by_schedule(schedule)
        self.assertEquals(len(buildings), 3)

        term.year = 2001
        schedule = _get_schedule(regid, term)

        buildings = get_buildings_by_schedule(schedule)
        self.assertEquals(buildings, None)
Ejemplo n.º 3
0
    def test_get_subject_guide_seattle(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '101':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/research")

                # has subject guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '100':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/friendly.php?s=research/pnw")

                # has subject guide link
                if section.curriculum_abbr == 'PHYS' and\
                        section.course_number == '121':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "%s?%s" % ("http://guides.lib.uw.edu/friendly.php",
                                   "s=research/physics_astronomy"))
Ejemplo n.º 4
0
 def test_must_displayed_separately(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         term = get_specific_term(2013, "summer")
         schedule = _get_schedule(regid, term)
         self.assertTrue(_must_displayed_separately(schedule))
Ejemplo n.º 5
0
 def test_must_displayed_separately(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         term = get_specific_term(2013, "summer")
         schedule = _get_schedule(regid, term)
         self.assertTrue(_must_displayed_separately(schedule))
Ejemplo n.º 6
0
    def test_multiple_instructors(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS,
                           RESTCLIENTS_IASYSTEM_DAO_CLASS=FDAO_IAS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            evals = None
            for section in schedule.sections:
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '102' and\
                        section.section_id == 'A':
                    evals = _get_evaluations_by_section_and_student(
                        section, 1033334)
                    break
            self.assertIsNotNone(evals)
            self.assertEqual(len(evals), 1)
            self.assertEqual(evals[0].section_sln, 13833)
            self.assertEqual(
                evals[0].eval_open_date,
                datetime.datetime(2013, 8, 23, 14, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(
                evals[0].eval_close_date,
                datetime.datetime(2013, 8, 29, 6, 59, 59, tzinfo=pytz.utc))

            self.assertEqual(len(evals[0].instructor_ids), 3)
            self.assertEqual(evals[0].instructor_ids[0], 123456781)
            self.assertEqual(evals[0].instructor_ids[1], 123456782)
            self.assertEqual(evals[0].instructor_ids[2], 123456798)
Ejemplo n.º 7
0
    def test_get_evaluations_by_section(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS,
                           RESTCLIENTS_IASYSTEM_DAO_CLASS=FDAO_IAS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "summer"
            section = Section()
            section.summer_term = "A-term"
            section.term = term
            schedule = _get_schedule(regid, term)
            evals = None
            for section in schedule.sections:
                if section.curriculum_abbr == 'ELCBUS':
                    evals = _get_evaluations_by_section_and_student(
                        section, 1443336)
                    break
            self.assertIsNotNone(evals)
            self.assertEqual(evals[0].section_sln, 13833)
            self.assertEqual(
                evals[0].eval_open_date,
                datetime.datetime(2013, 7, 02, 14, 0, tzinfo=pytz.utc))
            self.assertEqual(
Ejemplo n.º 8
0
    def test_get_evaluations_by_section(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS,
                           RESTCLIENTS_IASYSTEM_DAO_CLASS=FDAO_IAS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "summer"
            section = Section()
            section.summer_term = "A-term"
            section.term = term
            schedule = _get_schedule(regid, term)
            evals = None
            for section in schedule.sections:
                if section.curriculum_abbr == 'ELCBUS':
                    evals = _get_evaluations_by_section_and_student(section,
                                                                    1443336)
                    break
            self.assertIsNotNone(evals)
            self.assertEqual(evals[0].section_sln, 13833)
            self.assertEqual(evals[0].eval_open_date,
                             datetime.datetime(2013, 7, 02,
                                               14, 0,
                                               tzinfo=pytz.utc))
            self.assertEqual(evals[0].eval_close_date,
Ejemplo n.º 9
0
    def test_filter_schedule_sections_by_summer_term(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            # ensure it has both A and B terms
            has_a_term = False
            has_b_term = False
            for section in schedule.sections:
                if section.summer_term == "A-term":
                    has_a_term = True
                if section.summer_term == "B-term":
                    has_b_term = True
            self.assertTrue(has_a_term)
            self.assertTrue(has_b_term)

            filter_schedule_sections_by_summer_term(schedule, "A-term")
            # the B-term section no longer exists
            filtered_has_b_term = False
            filtered_has_a_term = False
            filtered_has_full_term = False
            for section in schedule.sections:
                if section.summer_term == "A-term":
                    filtered_has_a_term = True
                if section.summer_term == "B-term":
                    filtered_has_b_term = True
                if section.summer_term == "Full-term":
                    filtered_has_full_term = True

            self.assertFalse(filtered_has_b_term)
            self.assertTrue(filtered_has_full_term)
            self.assertTrue(filtered_has_a_term)
Ejemplo n.º 10
0
    def test_get_subject_guide_seattle(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '101':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/research")

                # has subject guide link
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '100':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/friendly.php?s=research/pnw")

                # has subject guide link
                if section.curriculum_abbr == 'PHYS' and\
                        section.course_number == '121':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "%s?%s" % ("http://guides.lib.uw.edu/friendly.php",
                                   "s=research/physics_astronomy"))
Ejemplo n.º 11
0
    def test_get_subject_guide_tacoma(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "12345678901234567890123456789012"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'ROLING' and\
                        section.course_number == '310':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/tacoma")

                if section.curriculum_abbr == 'T ARTS' and\
                        section.course_number == '110':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/tacoma")

                # has subject guide link
                if section.curriculum_abbr == 'ARCTIC' and\
                        section.course_number == '200':
                    self.assertEquals(get_subject_guide_by_section(section),
                                      "http://guides.lib.uw.edu/tacoma/art")
Ejemplo n.º 12
0
    def test_filter_schedule_sections_by_summer_term(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            # ensure it has both A and B terms
            has_a_term = False
            has_b_term = False
            for section in schedule.sections:
                if section.summer_term == "A-term":
                    has_a_term = True
                if section.summer_term == "B-term":
                    has_b_term = True
            self.assertTrue(has_a_term)
            self.assertTrue(has_b_term)

            filter_schedule_sections_by_summer_term(schedule, "A-term")
            # the B-term section no longer exists
            filtered_has_b_term = False
            filtered_has_a_term = False
            filtered_has_full_term = False
            for section in schedule.sections:
                if section.summer_term == "A-term":
                    filtered_has_a_term = True
                if section.summer_term == "B-term":
                    filtered_has_b_term = True
                if section.summer_term == "Full-term":
                    filtered_has_full_term = True

            self.assertFalse(filtered_has_b_term)
            self.assertTrue(filtered_has_full_term)
            self.assertTrue(filtered_has_a_term)
Ejemplo n.º 13
0
    def test_multiple_instructor(self):
        with self.settings(
            RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
            RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS,
            RESTCLIENTS_IASYSTEM_DAO_CLASS=FDAO_IAS,
        ):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            evals = None
            for section in schedule.sections:
                if section.curriculum_abbr == "TRAIN" and section.course_number == "102" and section.section_id == "A":
                    evals = _get_evaluations_by_section_and_student(section, 1033334)
                    break
            self.assertIsNotNone(evals)
            self.assertEqual(len(evals), 1)
            self.assertEqual(evals[0].section_sln, 13833)
            self.assertEqual(evals[0].eval_open_date, datetime.datetime(2013, 8, 23, 14, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(evals[0].eval_close_date, datetime.datetime(2013, 8, 29, 6, 59, 59, tzinfo=pytz.utc))

            self.assertEqual(len(evals[0].instructor_ids), 3)
            self.assertEqual(evals[0].instructor_ids[0], 123456781)
            self.assertEqual(evals[0].instructor_ids[1], 123456782)
            self.assertEqual(evals[0].instructor_ids[2], 123456798)
Ejemplo n.º 14
0
    def test_get_subject_guide_tacoma(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "12345678901234567890123456789012"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            for section in schedule.sections:
                # 404, general guide link
                if section.curriculum_abbr == 'ROLING' and\
                        section.course_number == '310':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/tacoma")

                if section.curriculum_abbr == 'T ARTS' and\
                        section.course_number == '110':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/tacoma")

                # has subject guide link
                if section.curriculum_abbr == 'ARCTIC' and\
                        section.course_number == '200':
                    self.assertEquals(
                        get_subject_guide_by_section(section),
                        "http://guides.lib.uw.edu/tacoma/art")
Ejemplo n.º 15
0
 def test_get_registered_summer_terms(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         term = get_specific_term(2013, "summer")
         schedule = _get_schedule(regid, term)
         data = _get_registered_summer_terms(schedule.sections)
         self.assertTrue(data["B"])
         self.assertTrue(data["A"])
Ejemplo n.º 16
0
 def test_get_registered_summer_terms(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         term = get_specific_term(2013, "summer")
         schedule = _get_schedule(regid, term)
         data = _get_registered_summer_terms(schedule.sections)
         self.assertTrue(data["B"])
         self.assertTrue(data["A"])
Ejemplo n.º 17
0
    def test_get_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2012
        term.quarter = "summer"
        schedule = _get_schedule(regid, term)

        buildings = get_buildings_by_schedule(schedule)
        self.assertEquals(len(buildings), 3)
Ejemplo n.º 18
0
    def test_get_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2012
        term.quarter = "summer"
        schedule = _get_schedule(regid, term)

        books = get_textbook_by_schedule(schedule)
        self.assertEquals(len(books), 1)
        self.assertEquals(books["13833"][0].title,
                          "2 P/S Tutorials In Introductory Physics")
Ejemplo n.º 19
0
    def test_get_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2012
        term.quarter = "summer"
        schedule = _get_schedule(regid, term)

        books = get_textbook_by_schedule(schedule)
        self.assertEquals(len(books), 1)
        self.assertEquals(books["13833"][0].title,
                          "2 P/S Tutorials In Introductory Physics")
Ejemplo n.º 20
0
    def test_get_verba_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2013
        term.quarter = "spring"
        schedule = _get_schedule(regid, term)

        returned_link = get_verba_link_by_schedule(schedule)

        expected_link = ("http://uw-seattle.verbacompare.com/m?"
                         "section_id=AB12345&quarter=spring")
        self.assertEquals(returned_link, expected_link)

        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2014
        term.quarter = "winter"
        schedule = _get_schedule(regid, term)
        self.assertRaises(DataFailureException, get_verba_link_by_schedule,
                          schedule)
Ejemplo n.º 21
0
    def test_get_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2012
        term.quarter = "summer"
        schedule = _get_schedule(regid, term)

        books = get_textbook_by_schedule(schedule)
        self.assertEquals(len(books), 5)
        self.assertEquals(books["13833"][0].title,
                          "Quantum Chemistry (6th Edition)")
        self.assertEquals(get_textbook_by_schedule(None), None)
Ejemplo n.º 22
0
    def test_get_verba_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2013
        term.quarter = "spring"
        schedule = _get_schedule(regid, term)

        returned_link = get_verba_link_by_schedule(schedule)

        expected_link = ("http://uw-seattle.verbacompare.com/m?"
                         "section_id=AB12345&quarter=spring")
        self.assertEquals(returned_link, expected_link)

        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2014
        term.quarter = "winter"
        schedule = _get_schedule(regid, term)
        self.assertRaises(DataFailureException,
                          get_verba_link_by_schedule,
                          schedule)
Ejemplo n.º 23
0
    def test_get_verba_by_schedule(self):
        regid = "9136CCB8F66711D5BE060004AC494FFE"
        term = Term()
        term.year = 2012
        term.quarter = "summer"
        schedule = _get_schedule(regid, term)

        expected_link = ("http://uw-seattle.verbacompare.com/m?"
                         "section_id=AB12345&quarter=summer")
        returned_link = get_verba_link_by_schedule(schedule)
        self.assertEquals(returned_link, expected_link)

        returned_link = get_verba_link_by_schedule(None)
        self.assertEquals(returned_link, None)
Ejemplo n.º 24
0
    def test_has_summer_quarter_section(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2012
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            self.assertTrue(has_summer_quarter_section(schedule))

            term = Term()
            term.year = 2012
            term.quarter = "autumn"
            self.assertRaises(DataFailureException, _get_schedule, regid, term)
Ejemplo n.º 25
0
    def test_primary_secondary(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            regid = "00000000000000000000000000000003"
            term = Term()
            term.year = 2012
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            colors = get_colors_by_regid_and_schedule(regid, schedule)

            self.assertEquals
            (colors["2012,summer,PHYS,121/A"], 1, "Primary gets the 1st color")
            msg = "Secondary gets the 1st color, secondary version"
            self.assertEquals(colors["2012,summer,PHYS,121/AC"], "1a", msg)
            msg = "Second secondary gets the 1st color, secondary version"
            self.assertEquals(colors["2012,summer,PHYS,121/AQ"], "1a", msg)
Ejemplo n.º 26
0
    def test_efs_before_end(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-09-01"
            cur_term = get_current_quarter(now_request)
            self.assertEqual(cur_term.year, 2013)
            self.assertEqual(cur_term.quarter, "autumn")

            cur_term = get_current_quarter(now_request)
            fall_efs_schedule = _get_schedule(regid, cur_term)
            self.assertIsNotNone(fall_efs_schedule)
            self.assertEqual(len(fall_efs_schedule.sections), 2)
Ejemplo n.º 27
0
    def test_efs_before_end(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-09-01"
            cur_term = get_current_quarter(now_request)
            self.assertEqual(cur_term.year, 2013)
            self.assertEqual(cur_term.quarter, "autumn")

            cur_term = get_current_quarter(now_request)
            fall_efs_schedule = _get_schedule(regid, cur_term)
            self.assertIsNotNone(fall_efs_schedule)
            self.assertEqual(len(fall_efs_schedule.sections), 2)
Ejemplo n.º 28
0
    def test_primary_secondary(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            regid = "00000000000000000000000000000003"
            term = Term()
            term.year = 2012
            term.quarter = "summer"
            schedule = _get_schedule(regid, term)
            colors = get_colors_by_regid_and_schedule(regid, schedule)

            self.assertEquals
            (colors["2012,summer,PHYS,121/A"], 1, "Primary gets the 1st color")
            msg = "Secondary gets the 1st color, secondary version"
            self.assertEquals(
                colors["2012,summer,PHYS,121/AC"], "1a", msg)
            msg = "Second secondary gets the 1st color, secondary version"
            self.assertEquals(
                colors["2012,summer,PHYS,121/AQ"], "1a", msg)
Ejemplo n.º 29
0
 def test_get_subject_guide_by_section(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         term = Term()
         term.year = 2013
         term.quarter = "spring"
         schedule = _get_schedule(regid, term)
         for section in schedule.sections:
             if section.curriculum_abbr == 'TRAIN':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://www.lib.washington.edu/subject/")
             if section.curriculum_abbr == 'PHYS':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.washington.edu/physics_astronomy")
Ejemplo n.º 30
0
    def test_crosslinks_lookup(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            data = get_indexed_data_for_regid(
                "12345678901234567890123456789012")

            now_request = RequestFactory().get("/")
            now_request.session = {}
            term = get_current_quarter(now_request)
            schedule = _get_schedule("12345678901234567890123456789012", term)
            canvas_data_by_course_id = get_indexed_by_decrosslisted(
                data, schedule.sections)

            physics = data['2013,spring,PHYS,121/A']
            self.assertEquals(physics.course_url,
                              'https://canvas.uw.edu/courses/149650')

            train = data['2013,spring,TRAIN,100/A']
            self.assertEquals(train.course_url,
                              'https://canvas.uw.edu/courses/249650')
Ejemplo n.º 31
0
 def test_get_subject_guide_bothell(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "FE36CCB8F66711D5BE060004AC494FCD"
         term = Term()
         term.year = 2013
         term.quarter = "spring"
         schedule = _get_schedule(regid, term)
         for section in schedule.sections:
             # has subject guide link
             if section.curriculum_abbr == 'BISSEB' and\
                     section.course_number == '259':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.uw.edu/bothell/businternational")
             # 404, general guide link
             if section.curriculum_abbr == 'BCWRIT' and\
                     section.course_number == '500':
                 self.assertEquals(get_subject_guide_by_section(section),
                                   "http://guides.lib.uw.edu/bothell/")
Ejemplo n.º 32
0
 def test_get_subject_guide_bothell(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "FE36CCB8F66711D5BE060004AC494FCD"
         term = Term()
         term.year = 2013
         term.quarter = "spring"
         schedule = _get_schedule(regid, term)
         for section in schedule.sections:
             # has subject guide link
             if section.curriculum_abbr == 'BISSEB' and\
                     section.course_number == '259':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.uw.edu/bothell/businternational")
             # 404, general guide link
             if section.curriculum_abbr == 'BCWRIT' and\
                     section.course_number == '500':
                 self.assertEquals(
                     get_subject_guide_by_section(section),
                     "http://guides.lib.uw.edu/bothell/")
Ejemplo n.º 33
0
    def test_winter_quarter_schedule(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-11-30"
            cur_term = get_current_quarter(now_request)
            self.assertEqual(cur_term.year, 2013)
            self.assertEqual(cur_term.quarter, "autumn")

            next_term = get_next_quarter(now_request)
            self.assertEqual(next_term.year, 2014)
            self.assertEqual(next_term.quarter, "winter")
            self.assertFalse(cur_term == next_term)

            winter2014_sche = _get_schedule(regid, next_term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
Ejemplo n.º 34
0
    def test_winter_quarter_schedule(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-11-30"
            cur_term = get_current_quarter(now_request)
            self.assertEqual(cur_term.year, 2013)
            self.assertEqual(cur_term.quarter, "autumn")

            next_term = get_next_quarter(now_request)
            self.assertEqual(next_term.year, 2014)
            self.assertEqual(next_term.quarter, "winter")
            self.assertFalse(cur_term == next_term)

            winter2014_sche = _get_schedule(regid, next_term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
Ejemplo n.º 35
0
    def test_crosslinks_lookup(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            data = get_indexed_data_for_regid(
                "12345678901234567890123456789012")

            now_request = RequestFactory().get("/")
            now_request.session = {}
            term = get_current_quarter(now_request)
            schedule = _get_schedule("12345678901234567890123456789012", term)
            canvas_data_by_course_id = get_indexed_by_decrosslisted(
                data, schedule.sections)

            physics = data['2013,spring,PHYS,121/A'].course
            self.assertEquals(physics.course_url,
                              'https://canvas.uw.edu/courses/249652')
            self.assertFalse(physics.is_unpublished())

            has_section_a = '2013,spring,TRAIN,100/A' in data
            self.assertTrue(has_section_a)

            train = data['2013,spring,TRAIN,100/A'].course
            self.assertEquals(train.course_url,
                              'https://canvas.uw.edu/courses/249650')
            self.assertTrue(train.is_unpublished())
Ejemplo n.º 36
0
    def test_save_seen_registration_obj(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-10"

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = get_specific_term(2014, "winter")
            winter2014_sche = _get_schedule(regid, term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
            registered_future_quarters = _get_registered_future_quarters(
                now_request,  winter2014_sche, None)

            user, created = User.objects.get_or_create(
                uwnetid='javerage',
                uwregid='9136CCB8F66711D5BE060004AC494FFE')

            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           registered_future_quarters[0])
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2014)
            self.assertEqual(model.quarter, "Winter")
            self.assertEqual(model.summer_term, "F")
            qset = SeenRegistration.objects.filter(user=user,
                                                   year=2014,
                                                   quarter="Winter",
                                                   summer_term="F",
                                                   )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           registered_future_quarters[0])
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(user=user,
                                                    year=2014,
                                                    quarter="Winter",
                                                    summer_term="F",
                                                    )
            self.assertEqual(len(qset1), 1)

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-5-10"

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = get_specific_term(2013, "summer")
            summer2013_sche = _get_schedule(regid, term)
            self.assertIsNotNone(summer2013_sche)
            self.assertEqual(len(summer2013_sche.sections), 3)
            registered_future_quarters = _get_registered_future_quarters(
                now_request,  summer2013_sche, None)
            self.assertEqual(len(registered_future_quarters), 2)

            quarter = registered_future_quarters[0]
            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2013)
            self.assertEqual(model.quarter, "Summer")
            self.assertEqual(model.summer_term, "A")
            qset = SeenRegistration.objects.filter(user=user,
                                                   year=2013,
                                                   quarter="Summer",
                                                   summer_term="A",
                                                   )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(user=user,
                                                    year=2013,
                                                    quarter="Summer",
                                                    summer_term="A",
                                                    )
            self.assertEqual(len(qset1), 1)

            quarter = registered_future_quarters[1]
            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2013)
            self.assertEqual(model.quarter, "Summer")
            self.assertEqual(model.summer_term, "B")
            qset = SeenRegistration.objects.filter(user=user,
                                                   year=2013,
                                                   quarter="Summer",
                                                   summer_term="B",
                                                   )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(user=user,
                                                    year=2013,
                                                    quarter="Summer",
                                                    summer_term="B",
                                                    )
            self.assertEqual(len(qset1), 1)
Ejemplo n.º 37
0
    def test_multiple_evals(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS,
                           RESTCLIENTS_IASYSTEM_DAO_CLASS=FDAO_IAS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            evals = None
            for section in schedule.sections:
                if section.curriculum_abbr == 'TRAIN' and\
                        section.course_number == '100' and\
                        section.section_id == 'A':
                    evals = _get_evaluations_by_section_and_student(
                        section, 1033334)
                    break
            self.assertIsNotNone(evals)
            self.assertEqual(len(evals), 3)
            self.assertEqual(evals[0].section_sln, 17169)
            self.assertEqual(
                evals[0].eval_open_date,
                datetime.datetime(2013, 5, 30, 15, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(
                evals[0].eval_close_date,
                datetime.datetime(2013, 7, 1, 7, 59, 59, tzinfo=pytz.utc))
            self.assertFalse(evals[0].is_completed)
            self.assertEqual(
                evals[1].eval_open_date,
                datetime.datetime(2013, 6, 5, 7, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(
                evals[1].eval_close_date,
                datetime.datetime(2013, 6, 17, 6, 59, 59, tzinfo=pytz.utc))
            self.assertFalse(evals[1].is_completed)
            self.assertEqual(
                evals[2].eval_open_date,
                datetime.datetime(2013, 6, 10, 7, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(
                evals[2].eval_close_date,
                datetime.datetime(2013, 6, 19, 6, 59, 59, tzinfo=pytz.utc))
            self.assertTrue(evals[2].is_completed)
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-05-30"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertEqual(len(json_data), 0)

            # open dates of 1 eval
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-05-31"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data), 1)
            self.assertEqual(json_data[0]['close_date'],
                             "2013-07-01 07:59:59 UTC+0000")
            # after open dates of 1 eval
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-04"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data), 1)

            # after open dates of two evals
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-05"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data), 2)
            self.assertEqual(json_data[0]['close_date'],
                             "2013-07-01 07:59:59 UTC+0000")
            self.assertEqual(json_data[1]['close_date'],
                             "2013-06-17 06:59:59 UTC+0000")

            # after open dates of three evals
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-10"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data), 2)

            # after close date of one eval
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-17"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertEqual(len(json_data), 1)
            self.assertEqual(json_data[0]['close_date'],
                             "2013-07-01 07:59:59 UTC+0000")

            # after close date of two evals
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-19"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertEqual(len(json_data), 1)

            # after close date of last eval
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-07-02"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertEqual(len(json_data), 0)
Ejemplo n.º 38
0
    def test_save_seen_registration_obj(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-10"

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = get_specific_term(2014, "winter")
            winter2014_sche = _get_schedule(regid, term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
            registered_future_quarters = _get_registered_future_quarters(
                now_request, winter2014_sche, None)

            user, created = User.objects.get_or_create(
                uwnetid='javerage', uwregid='9136CCB8F66711D5BE060004AC494FFE')

            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           registered_future_quarters[0])
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2014)
            self.assertEqual(model.quarter, "Winter")
            self.assertEqual(model.summer_term, "F")
            qset = SeenRegistration.objects.filter(
                user=user,
                year=2014,
                quarter="Winter",
                summer_term="F",
            )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           registered_future_quarters[0])
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(
                user=user,
                year=2014,
                quarter="Winter",
                summer_term="F",
            )
            self.assertEqual(len(qset1), 1)

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-5-10"

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = get_specific_term(2013, "summer")
            summer2013_sche = _get_schedule(regid, term)
            self.assertIsNotNone(summer2013_sche)
            self.assertEqual(len(summer2013_sche.sections), 3)
            registered_future_quarters = _get_registered_future_quarters(
                now_request, summer2013_sche, None)
            self.assertEqual(len(registered_future_quarters), 2)

            quarter = registered_future_quarters[0]
            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2013)
            self.assertEqual(model.quarter, "Summer")
            self.assertEqual(model.summer_term, "A")
            qset = SeenRegistration.objects.filter(
                user=user,
                year=2013,
                quarter="Summer",
                summer_term="A",
            )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(
                user=user,
                year=2013,
                quarter="Summer",
                summer_term="A",
            )
            self.assertEqual(len(qset1), 1)

            quarter = registered_future_quarters[1]
            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2013)
            self.assertEqual(model.quarter, "Summer")
            self.assertEqual(model.summer_term, "B")
            qset = SeenRegistration.objects.filter(
                user=user,
                year=2013,
                quarter="Summer",
                summer_term="B",
            )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(
                user=user,
                year=2013,
                quarter="Summer",
                summer_term="B",
            )
            self.assertEqual(len(qset1), 1)
Ejemplo n.º 39
0
    def test_get_registered_future_quarters(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            now_request = RequestFactory().get("/")
            now_request.session = {}

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term1 = get_specific_term(2013, "summer")
            schedule1 = _get_schedule(regid, term1)
            self.assertEqual(len(schedule1.sections), 3)

            term2 = get_specific_term(2013, "autumn")
            schedule2 = _get_schedule(regid, term2)
            self.assertEqual(len(schedule2.sections), 2)

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            terms = _get_registered_future_quarters(now_request, None, None)
            self.assertEqual(len(terms), 0)

            # MUWM-3010
            # Baseline pre-summer
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-04-01"

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            # Summer has started - so no a-term
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 2)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "b-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Autumn")
            self.assertEqual(terms[1]['summer_term'], "")

            # Summer b-term has started - so no a-term or b-term
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-07-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 1)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Autumn")
            self.assertEqual(terms[0]['summer_term'], "")

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-10"
            term = get_specific_term(2014, "winter")
            winter2014_sche = _get_schedule(regid, term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
            registered_future_quarters =\
                _get_registered_future_quarters(now_request,
                                                winter2014_sche,
                                                None)

            self.assertEqual(len(registered_future_quarters), 1)
            term1 = registered_future_quarters[0]
            self.assertEqual(term1["quarter"], "Winter")
            self.assertEqual(term1["year"], 2014)
            self.assertEqual(term1["section_count"], 5)
Ejemplo n.º 40
0
    def test_multiple_instructor(self):
        with self.settings(
            RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
            RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS,
            RESTCLIENTS_IASYSTEM_DAO_CLASS=FDAO_IAS,
        ):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = Term()
            term.year = 2013
            term.quarter = "spring"
            schedule = _get_schedule(regid, term)
            evals = None
            for section in schedule.sections:
                if section.curriculum_abbr == "TRAIN" and section.course_number == "100" and section.section_id == "A":
                    evals = _get_evaluations_by_section_and_student(section, 1033334)
                    break
            self.assertIsNotNone(evals)
            self.assertEqual(len(evals), 3)
            self.assertEqual(evals[0].section_sln, 17169)
            self.assertEqual(evals[0].eval_open_date, datetime.datetime(2013, 5, 30, 15, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(evals[0].eval_close_date, datetime.datetime(2013, 7, 1, 7, 59, 59, tzinfo=pytz.utc))
            self.assertEqual(evals[1].eval_open_date, datetime.datetime(2013, 6, 5, 7, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(evals[1].eval_close_date, datetime.datetime(2013, 6, 17, 6, 59, 59, tzinfo=pytz.utc))
            self.assertEqual(evals[2].eval_open_date, datetime.datetime(2013, 6, 10, 7, 0, 0, tzinfo=pytz.utc))
            self.assertEqual(evals[2].eval_close_date, datetime.datetime(2013, 6, 19, 6, 59, 59, tzinfo=pytz.utc))
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-05-30"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNone(json_data)
            # after show date and open dates of 1 eval
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-05-31"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data["evals"]), 1)
            self.assertEqual(json_data["close_date"], "2013-07-01T07:59:59+00:00")
            # after open dates of 1 eval
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-04"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data["evals"]), 1)
            self.assertEqual(json_data["close_date"], "2013-07-01T07:59:59+00:00")
            # after open dates of two evals
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-05"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data["evals"]), 2)
            self.assertEqual(json_data["close_date"], "2013-06-17T06:59:59+00:00")
            # after open dates of three evals
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-10"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data["evals"]), 3)
            self.assertEqual(json_data["close_date"], "2013-06-17T06:59:59+00:00")
            # after close date of one eval
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-17"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertEqual(len(json_data["evals"]), 2)
            self.assertEqual(json_data["close_date"], "2013-06-19T06:59:59+00:00")
            # after close date of two evals
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-19"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertEqual(len(json_data["evals"]), 1)
            self.assertEqual(json_data["close_date"], "2013-07-01T07:59:59+00:00")
Ejemplo n.º 41
0
    def test_get_registered_future_quarters(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            now_request = RequestFactory().get("/")
            now_request.session = {}

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term1 = get_specific_term(2013, "summer")
            schedule1 = _get_schedule(regid, term1)
            self.assertEqual(len(schedule1.sections), 3)

            term2 = get_specific_term(2013, "autumn")
            schedule2 = _get_schedule(regid, term2)
            self.assertEqual(len(schedule2.sections), 2)

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            terms = _get_registered_future_quarters(now_request, None, None)
            self.assertEqual(len(terms), 0)

            # MUWM-3010
            # Baseline pre-summer
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-04-01"

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            # Summer has started - so no a-term
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 2)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "b-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Autumn")
            self.assertEqual(terms[1]['summer_term'], "")

            # Summer b-term has started - so no a-term or b-term
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-07-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 1)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Autumn")
            self.assertEqual(terms[0]['summer_term'], "")

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-10"
            term = get_specific_term(2014, "winter")
            winter2014_sche = _get_schedule(regid, term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
            registered_future_quarters =\
                _get_registered_future_quarters(now_request,
                                                winter2014_sche,
                                                None)

            self.assertEqual(len(registered_future_quarters), 1)
            term1 = registered_future_quarters[0]
            self.assertEqual(term1["quarter"], "Winter")
            self.assertEqual(term1["year"], 2014)
            self.assertEqual(term1["section_count"], 5)
Ejemplo n.º 42
0
    def test_get_registered_future_quarters(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            now_request = RequestFactory().get("/")
            now_request.session = {}

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term1 = _get_term_by_year_and_quarter(2013, "summer")
            schedule1 = _get_schedule(regid, term1)
            self.assertEqual(len(schedule1.sections), 3)

            term2 = _get_term_by_year_and_quarter(2013, "autumn")
            schedule2 = _get_schedule(regid, term2)
            self.assertEqual(len(schedule2.sections), 1)

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            terms = _get_registered_future_quarters(now_request, None, None)
            self.assertEqual(len(terms), 0)

            # MUWM-3010
            # Baseline pre-summer
            now_request.session["myuw_override_date"] = "2013-04-01"

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            # Summer has started - so no a-term
            now_request.session["myuw_override_date"] = "2013-06-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 2)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "b-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Autumn")
            self.assertEqual(terms[1]['summer_term'], "")

            # Summer b-term has started - so no a-term or b-term
            now_request.session["myuw_override_date"] = "2013-07-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 1)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Autumn")
            self.assertEqual(terms[0]['summer_term'], "")