示例#1
0
 def test_missing_current_term(self):
     url = reverse("myuw_iasystem_api")
     get_user('err_user')
     self.client.login(username='******',
                       password=get_user_pass('err_user'))
     response = self.client.get(url)
     self.assertEquals(response.status_code, 404)
示例#2
0
 def test_invalid_books(self):
     url = reverse("myuw_library_api")
     get_user('nouser')
     self.client.login(username='******',
                       password=get_user_pass('nouser'))
     response = self.client.get(url)
     self.assertEquals(response.status_code, 404)
示例#3
0
 def test_support_links(self):
     url = reverse("myuw_date_override")
     get_user('jbothell')
     self.client.login(username='******',
                       password=get_user_pass('jbothell'))
     response = self.client.get(url)
     self.assertEquals(response.status_code, 200)
示例#4
0
文件: books.py 项目: fanglinfang/myuw
    def test_javerage_books(self):
        url = reverse("myuw_book_api",
                      kwargs={'year': 2013,
                              'quarter': 'spring',
                              'summer_term': ''})
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)

        self.assertEquals(data["verba_link"],
                          ("%s/m?section_id=AB12345&quarter=spring" %
                           VERBACOMPARE_URL_PREFIX))
        self.assertEquals(
            data["18545"][0]["cover_image_url"],
            ("%s?isbn=9780878935970&key=46c9ef715edb2ec69517e2c8e6ec9c18" %
             IMAGE_URL_PREFIX))
        self.assertEquals(len(data["18545"][0]["authors"]), 1)
        self.assertEquals(data["18545"][0]["is_required"], True)
        self.assertEquals(data["18545"][0]["price"], None)
        self.assertEquals(data["18545"][0]["used_price"], None)
        self.assertEquals(data["18545"][0]["isbn"], '9780878935970')
        self.assertEquals(data["18545"][0]["notes"], 'required')

        self.assertEquals(data["18545"][1]["price"], 44.0)
示例#5
0
    def test_past_quarter(self):
        url = reverse("myuw_future_schedule_api",
                      kwargs={'year': 2013,
                              'quarter': 'winter'})
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 410)

#        session = self.client.session
#        session["myuw_override_date"] = "2013-03-26"
#        session.save()
#        response = self.client.get(url)
#        self.assertEquals(response.status_code, 410)

        session = self.client.session
        session["myuw_override_date"] = "2013-03-27"
        session.save()
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        session = self.client.session
        session["myuw_override_date"] = "2013-04-01"
        session.save()
        response = self.client.get(url)
        self.assertEquals(response.status_code, 410)
示例#6
0
    def test_required_migration_desktop_user(self):
        del settings.MYUW_OPTIN_SWITCH_PATH

        # Delete any preference that might have been set, to test the
        # default state.
        UserMigrationPreference.objects.all().delete()
        username = "******"
        url = reverse("myuw_home")
        get_user(username)
        self.client.login(username=username,
                          password=get_user_pass('random'))
        response = self.client.get(url, **_get_desktop_args())

        # By default, they get sent to the new site
        self.assertEquals(response.status_code, 200)

        # Test with a saved preference of the old site
        obj = UserMigrationPreference.objects.create(username=username,
                                                     use_legacy_site=True)

        response = self.client.get(url, **_get_desktop_args())

        valid_url = "http://some-test-server/myuw"
        self.assertEquals(response.status_code, 302)
        self.assertEquals(response.get("Location"), valid_url)

        # Test with a saved preference for the new site
        obj.use_legacy_site = False
        obj.save()
        response = self.client.get(url, **_get_desktop_args())
        self.assertEquals(response.status_code, 200)
示例#7
0
    def test_javerage_email(self):
        url = reverse("myuw_myplan_api",
                      kwargs={'year': 2013,
                              'quarter': 'autumn'})
        get_user('jinter')
        self.client.login(username='******',
                          password=get_user_pass('jinter'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        data = json.loads(response.content)
        self.assertEquals(len(data["terms"][0]["courses"]), 5)
        self.assertEquals(data["terms"][0]["has_unready_courses"], True)
        self.assertEquals(data["terms"][0]["has_ready_courses"], False)
        self.assertEquals(data["terms"][0]["has_sections"], False)
        self.assertEquals(data["terms"][0]["ready_count"], 0)
        self.assertEquals(data["terms"][0]["unready_count"], 5)

        url = reverse("myuw_myplan_api",
                      kwargs={'year': 2013,
                              'quarter': 'spring'})
        get_user('jinter')
        self.client.login(username='******',
                          password=get_user_pass('jinter'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
        data = json.loads(response.content)

        self.assertEquals(len(data["terms"][0]["courses"]), 6)
        self.assertEquals(data["terms"][0]["has_unready_courses"], False)
        self.assertEquals(data["terms"][0]["has_ready_courses"], True)
        self.assertEquals(data["terms"][0]["has_sections"], True)
        self.assertEquals(data["terms"][0]["ready_count"], 6)
        self.assertEquals(data["terms"][0]["unready_count"], 0)
示例#8
0
    def test_javerage_current_term(self):
        url = reverse("myuw_current_schedule")
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)

        self.assertEquals(data["term"]["year"], 2013)
        self.assertEquals(data["term"]["quarter"], 'Spring')
        self.assertEquals(len(data["sections"]), 5)
        for section in data["sections"]:
            if section["curriculum_abbr"] == "PHYS" and\
                    section["course_number"] == "121" and\
                    section["section_id"] == "A":
                self.assertEquals(section["canvas_url"],
                                  "https://canvas.uw.edu/courses/249652")
                self.assertEquals(section["canvas_name"],
                                  "MECHANICS")

            if section["curriculum_abbr"] == "TRAIN" and\
                    section["course_number"] == "100" and\
                    section["section_id"] == "A":
                self.assertRaises(KeyError, section.get("canvas_url"))
示例#9
0
    def test_summer_terms(self):
        url = reverse("myuw_current_schedule")
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))
        session = self.client.session
        session["myuw_override_date"] = "2013-07-06"
        session.save()

        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)

        self.assertEquals(data["term"]["year"], 2013)
        self.assertEquals(data["term"]["quarter"], 'Summer')
        self.assertEquals(data["summer_term"], "a-term")

        session = self.client.session
        session["myuw_override_date"] = "2013-07-25"
        session.save()

        response = self.client.get(url)
        data = json.loads(response.content)
        self.assertEquals(data["summer_term"], "b-term")
示例#10
0
 def test_missing_current_term(self):
     url = reverse("myuw_current_schedule")
     get_user('jerror')
     self.client.login(username='******',
                       password=get_user_pass('jerror'))
     response = self.client.get(url)
     self.assertEquals(response.status_code, 543)
示例#11
0
 def test_undergrad_access(self):
     url = reverse("myuw_home")
     get_user('jbothell')
     self.client.login(username='******',
                       password=get_user_pass('jbothell'))
     response = self.client.get(
         url, HTTP_USER_AGENT="Lynx/2.8.2rel.1 libwww-FM/2.14")
     self.assertEquals(response.status_code, 200)
示例#12
0
文件: page.py 项目: vegitron/myuw
 def test_not_in_pws_applicant_access(self):
     url = reverse("myuw_home")
     get_user('jnone')
     self.client.login(username='******',
                       password=get_user_pass('jnone'))
     response = self.client.get(url,
                                HTTP_USER_AGENT='Fake Android Mobile')
     self.assertEquals(response.status_code, 302)
示例#13
0
文件: hfs.py 项目: mattventura/myuw
    def test_error(self):
        url = reverse("myuw_hfs_api")
        get_user('jerror')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))

        response = self.client.get(url)
        self.assertEquals(response.status_code, 543)
示例#14
0
    def test_none_current_term(self):
        url = reverse("myuw_current_schedule")
        get_user('none')
        self.client.login(username='******', password=get_user_pass('none'))
        response = self.client.get(url)

        self.assertEquals(response.status_code, 404)
        self.assertEquals(response.content, 'Data not found')
示例#15
0
    def test_required_migration_desktop_user(self):
        del settings.MYUW_MANDATORY_SWITCH_PATH
        url = reverse("myuw_home")
        get_user('47e5e5631c3d3e0ad70047290a629c4c')
        self.client.login(username='******',
                          password=get_user_pass('random'))
        response = self.client.get(url, **_get_desktop_args())

        self.assertEquals(response.status_code, 200)
示例#16
0
    def test_random_desktop_user(self):
        url = reverse("myuw_home")
        get_user('random2')
        self.client.login(username='******', password=get_user_pass('random'))
        response = self.client.get(url, **_get_desktop_args())

        valid_url = "http://some-test-server/myuw"
        self.assertEquals(response.status_code, 302)
        self.assertEquals(response.get("Location"), valid_url)
示例#17
0
    def test_student_mobile(self):
        url = reverse("myuw_home")
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))
        response = self.client.get(url, **_get_mobile_args())

        valid_url = "http://testserver%s" % reverse("myuw_home")
        self.assertEquals(response.status_code, 200)
示例#18
0
    def test_random_non_student_mobile_override_url(self):
        url = reverse("myuw_home")
        get_user('staff')
        self.client.login(username='******', password=get_user_pass('staff'))
        response = self.client.get(url, **_get_mobile_args())

        valid_url = "http://some-test-server/myuw"
        self.assertEquals(response.status_code, 302)
        self.assertEquals(response.get("Location"), valid_url)
示例#19
0
文件: page.py 项目: vegitron/myuw
 def test_undergrad_access(self):
     url = reverse("myuw_home")
     get_user('jbothell')
     self.client.login(username='******',
                       password=get_user_pass('jbothell'))
     response = self.client.get(
         url,
         HTTP_USER_AGENT="Lynx/2.8.2rel.1 libwww-FM/2.14")
     self.assertEquals(response.status_code, 200)
示例#20
0
 def test_error(self):
     url = reverse("myuw_myplan_api",
                   kwargs={'year': 2013,
                           'quarter': 'spring'})
     get_user('jerror')
     self.client.login(username='******',
                       password=get_user_pass('jerror'))
     response = self.client.get(url)
     self.assertEquals(response.status_code, 200)
     self.assertEquals(response.content, '[]')
示例#21
0
    def test_random_non_student_mobile(self):
        del settings.MYUW_USER_SERVLET_URL
        url = reverse("myuw_home")
        get_user('random')
        self.client.login(username='******', password=get_user_pass('random'))
        response = self.client.get(url, **_get_mobile_args())

        # This is the default...
        valid_url = "https://myuw.washington.edu/servlet/user"
        self.assertEquals(response.status_code, 302)
        self.assertEquals(response.get("Location"), valid_url)
示例#22
0
 def test_logout(self):
     logout_url = reverse("myuw_logout")
     home_url = reverse("myuw_home")
     get_user('javerage')
     self.client.login(username='******',
                       password=get_user_pass('javerage'))
     old_session_id = self.client.cookies['sessionid'].value
     response = self.client.get(logout_url, **_get_desktop_args())
     new_session_id = self.client.cookies['sessionid'].value
     self.assertNotEqual(old_session_id, new_session_id)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response["Location"], LOGOUT_URL)
示例#23
0
文件: hfs.py 项目: mattventura/myuw
    def test_eight(self):
        url = reverse("myuw_hfs_api")
        get_user('eight')
        self.client.login(username='******', password=get_user_pass('eight'))

        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)
        self.assertEquals(data["employee_husky_card"], None)
        self.assertEquals(data["resident_dining"]["balance"], 15.1)
        self.assertEquals(data["student_husky_card"]["balance"], 100.23)
示例#24
0
 def test_logout(self):
     logout_url = reverse("myuw_logout")
     home_url = reverse("myuw_home")
     get_user('javerage')
     self.client.login(username='******',
                       password=get_user_pass('javerage'))
     old_session_id = self.client.cookies['sessionid'].value
     response = self.client.get(logout_url, **_get_desktop_args())
     new_session_id = self.client.cookies['sessionid'].value
     self.assertNotEqual(old_session_id, new_session_id)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response["Location"], LOGOUT_URL)
示例#25
0
    def test_eight_current_term(self):
        url = reverse("myuw_current_schedule")
        get_user('eight')
        self.client.login(username='******', password=get_user_pass('eight'))
        response = self.client.get(url)

        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)

        self.assertEquals(data["term"]["year"], 2013)
        self.assertEquals(data["term"]["quarter"], 'Spring')
        self.assertEquals(len(data["sections"]), 8)
示例#26
0
    def test_academics_links(self):
        url = reverse("myuw_links_api",
                      kwargs={'category_id': 'academics'})
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)

        self.assertEquals(data["link_data"][0]["subcategory"], "Registration")
        self.assertTrue(len(data["link_data"][0]["links"]) > 1)
示例#27
0
    def test_errors(self):
        url = reverse("myuw_finance_api")
        get_user('jerror')
        self.client.login(username='******',
                          password=get_user_pass('jerror'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 543)

        get_user('staff')
        self.client.login(username='******',
                          password=get_user_pass('staff'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 404)
示例#28
0
    def test_jerror(self):
        url = reverse("myuw_profile_api")
        get_user('jerror')
        self.client.login(username='******',
                          password=get_user_pass('jerror'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 543)

        get_user('nouser')
        self.client.login(username='******',
                          password=get_user_pass('nouser'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 404)
示例#29
0
    def test_javerage(self):
        url = reverse("myuw_book_api", kwargs={"year": 2013, "quarter": "spring", "summer_term": ""})
        get_user("javerage")
        self.client.login(username="******", password=get_user_pass("javerage"))

        response = self.client.put(url)
        self.assertEquals(response.status_code, 405)

        response = self.client.post(url)
        self.assertEquals(response.status_code, 405)

        response = self.client.delete(url)
        self.assertEquals(response.status_code, 405)
示例#30
0
文件: hfs.py 项目: fanglinfang/myuw
    def test_bad_user(self):
        url = reverse("myuw_hfs_api")
        get_user('err-user')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))

        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)
        self.assertFalse("employee_husky_card" in data)
        self.assertFalse("resident_dining" in data)
        self.assertFalse("student_husky_card" in data)
示例#31
0
文件: grad.py 项目: mattventura/myuw
    def test_error(self):
        url = reverse("myuw_grad_api")
        get_user('none')
        self.client.login(username='******',
                          password=get_user_pass('none'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 404)
        self.assertEquals(response.content, 'Data not found')

        get_user('jerror')
        self.client.login(username='******',
                          password=get_user_pass('jerror'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 543)
示例#32
0
    def test_eight_2013_spring(self):
        url = reverse("myuw_iasystem_api")
        get_user('eight')
        self.client.login(username='******', password=get_user_pass('eight'))
        session = self.client.session
        session["myuw_override_date"] = "2013-06-08"
        session.save()
        response = self.client.get(url)

        self.assertEquals(response.status_code, 200)
        data = json.loads(response.content)
        self.assertEquals(data["term"]["year"], 2013)
        self.assertEquals(data["term"]["quarter"], 'Spring')
        self.assertEquals(len(data["sections"]), 8)
示例#33
0
    def test_javerage_books(self):
        url = reverse("myuw_library_api")
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)

        data = json.loads(response.content)

        self.assertEquals(data["next_due"], "2014-05-27")
        self.assertEquals(data["holds_ready"], 1)
        self.assertEquals(data["fines"], 0)
        self.assertEquals(data["items_loaned"], 1)
示例#34
0
    def test_javerage(self):
        url = reverse("myuw_book_api",
                      kwargs={
                          'year': 2013,
                          'quarter': 'spring',
                          'summer_term': ''
                      })
        get_user('javerage')
        self.client.login(username='******',
                          password=get_user_pass('javerage'))

        response = self.client.put(url)
        self.assertEquals(response.status_code, 405)

        response = self.client.post(url)
        self.assertEquals(response.status_code, 405)

        response = self.client.delete(url)
        self.assertEquals(response.status_code, 405)
示例#35
0
    def test_desktop_redirect(self):
        url = reverse("myuw_home")
        get_user('testcal1')
        self.client.login(username='******',
                          password=get_user_pass('testcal1'))
        response = self.client.get(
            url,
            HTTP_USER_AGENT="Mozilla/4.0 (compatible; MSIE 5.01; WebISOGet")
        self.assertEquals(response.status_code, 302)

        get_user('staff')
        self.client.login(username='******', password=get_user_pass('staff'))
        response = self.client.get(
            url,
            HTTP_USER_AGENT="Mozilla/4.0 (compatible; MSIE 5.01; WebISOGet")
        self.assertEquals(response.status_code, 302)

        get_user('faculty')
        self.client.login(username='******',
                          password=get_user_pass('faculty'))
        response = self.client.get(
            url,
            HTTP_USER_AGENT="Mozilla/4.0 (compatible; MSIE 5.01; WebISOGet")
        self.assertEquals(response.status_code, 302)
示例#36
0
 def test_not_in_pws_applicant_access(self):
     url = reverse("myuw_home")
     get_user('jnone')
     self.client.login(username='******', password=get_user_pass('jnone'))
     response = self.client.get(url, HTTP_USER_AGENT='Fake Android Mobile')
     self.assertEquals(response.status_code, 302)