Skip to content

Commit deded3b

Browse files
authored
2 parents a6a49bb + 2f8ae9e commit deded3b

File tree

16 files changed

+282
-170
lines changed

16 files changed

+282
-170
lines changed

cypress/fixtures/resources/all.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
},
104104
{
105105
"title": "Check Your Degree Progress (DARS)",
106-
"url": "https://myplan.uw.edu/dars"
106+
"url": "https://myplan.uw.edu/audit/#/degree"
107107
},
108108
{
109109
"title": "MyPlan",

cypress/fixtures/resources/pinned.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
},
6464
{
6565
"title": "Check Your Degree Progress (DARS)",
66-
"url": "https://myplan.uw.edu/dars"
66+
"url": "https://myplan.uw.edu/audit/#/degree"
6767
},
6868
{
6969
"title": "MyPlan",

myuw/data/category_links_import.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ PageAcademics,Registration,all,https://registrar.washington.edu/enrollment-and-d
1010
PageAcademics,Registration,all,,,https://www.washington.edu/students/timeschd/,UW Seattle Time Schedule,https://www.uwb.edu/registration/time,UW Bothell Time Schedule,https://www.tacoma.uw.edu/ts-quicksearch/,UW Tacoma Time Schedule,no,,,,,,,,,,,,,
1111
PageAcademics,Registration,pce,https://www.washington.edu/students/timeschd/95index.html,Professional & Continuing Education Time Schedule,,,,,,,no,,,,,,,,,,,,,
1212
PageAcademics,Registration,all,,,http://www.washington.edu/students/crscat/,Course Catalog,https://www.washington.edu/students/crscatb/,Course Catalog,https://www.washington.edu/students/crscatt/,Course Catalog,no,,,,,,,,,,,,,
13-
PageAcademics,Registration,all,https://myplan.uw.edu/dars,Degree Audit (DARS),,,,,,,yes,,,,,,,,,,,,,
13+
PageAcademics,Registration,all,https://myplan.uw.edu/audit/#/degree,Degree Audit (DARS),,,,,,,yes,,,,,,,,,,,,,
1414
PageAcademics,Registration,all,https://myplan.uw.edu/plan/,MyPlan,,,,,,,yes,,,,,,,,,,,,,
1515
PageAcademics,Registration,all,https://sdb.admin.uw.edu/students/uwnetid/register.asp,Register with SLN,,,,,,,yes,,,,,,,,,,,,,
1616
PageAcademics,Registration,all,,,https://sdb.admin.uw.edu/timeschd/uwnetid/findschd.asp,Schedule Finder,https://sdb.admin.uw.edu/timeschd/uwnetid/findschd.asp,Schedule Finder,,,yes,,,,,,,,,,,,,

myuw/data/resource_link_import.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Academics,Grades & Transcripts,all,https://sdb.admin.uw.edu/students/uwnetid/uno
1717
Academics,Graduation,all,,,https://registrar.washington.edu/students/graduation-commencement-and-diplomas/,Applying for Graduation,https://www.uwb.edu/registration/graduation/apply,Applying for Graduation,https://www.tacoma.uw.edu/uwt/registrar/graduation-procedures,Applying to Graduate,no
1818
Academics,Registration,all,,,http://www.washington.edu/students/reg/calendar.html,Academic Calendar,http://www.uwb.edu/calendars,UW Bothell Academic Calendar,http://www.washington.edu/students/reg/calendar.html,Academic Calendar,no
1919
Academics,Registration,all,,,http://www.washington.edu/students/crscat/,Course Catalog,http://www.washington.edu/students/crscatb/,Course Catalog,http://www.washington.edu/students/crscatt/,Course Catalog,no
20-
Academics,Registration,all,https://myplan.uw.edu/dars,Check Your Degree Progress (DARS),,,,,,,no
20+
Academics,Registration,all,https://myplan.uw.edu/audit/#/degree,Check Your Degree Progress (DARS),,,,,,,no
2121
Academics,Registration,all,https://myplan.uw.edu/,MyPlan,,,,,,,no
2222
Academics,Registration,all,https://notify.uw.edu/,Notify.UW,,,,,,,no
2323
Academics,Registration,all,http://dawgpath.uw.edu,DawgPath,,,,,,,no

myuw/resources/sws/file/student/v5/course/2013_spring_BESS_102/AB.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Text": "M W"
5151
},
5252
"DaysOfWeekToBeArranged": false,
53-
"EndTime": "10:20",
53+
"EndTime": "12:20",
5454
"Instructors": [],
5555
"MeetingIndex": "1",
5656
"MeetingType": "quiz",

myuw/templates/500.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ <h2 style="font-size:15px; font-weight: bold;">In the meantime, you may find wha
177177
<li><a href="https://www.hfs.washington.edu/olco/Secure/AccountSummary.aspx" target="_blank">HFS Account Summary</a></li>
178178
<li><a href="https://www.washington.edu/students/timeschd/" target="_blank">Time Schedule</a></li>
179179
<li><a href="https://myplan.uw.edu/" target="_blank">MyPlan</a></li>
180-
<li><a href="https://myplan.uw.edu/dars" target="_blank">Degree Audit (DARS)</a></li>
180+
<li><a href="https://myplan.uw.edu/audit/#/degree" target="_blank">Degree Audit (DARS)</a></li>
181181
<li><a href="https://sdb.admin.uw.edu/students/uwnetid/unofficial.asp" target="_blank">Unofficial Transcript</a></li>
182182
<li><a href="https://sdb.admin.uw.edu/sisMyUWClass/uwnetid/default.aspx" target="_blank">My Class Instructor Resources</a></li>
183183
<li><a href="https://gradepage.uw.edu/" target="_blank">GradePage</a></li>

myuw/templates/admin/notice_edit.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ <h3>Notice Content</h3>
6262
<label class="" for="notice_content">Content</label>
6363
<textarea id="notice_content" name='content' class="form-control">{% if notice.content %}{{ notice.content }}{% endif %}</textarea>
6464
<p class="{% if content_error %}text-danger{% else %}help-block small{% endif %}">Required</p>
65-
<p class="text-muted small">HTML content is enabled. &lt;a&gt;, &lt;strong&gt;, &lt;em&gt;, &lt;abbr&gt;, &lt;br&gt;, &lt;p&gt;, &lt;ul&gt;, &lt;ol&gt;, &lt;li&gt;, etc...></p>
65+
<p class="text-muted small">HTML content is enabled. Please <a href="https://www.freeformatter.com/html-validator.html">validate the content</a></p>
6666

6767
</div>
6868

myuw/test/views/test_notice_admin.py

+108-75
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,91 @@
11
# Copyright 2022 UW-IT, University of Washington
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import json
5-
from myuw.test.api import missing_url, MyuwApiTest
4+
from unittest.mock import patch
5+
from myuw.test.api import MyuwApiTest
66
from django.test.client import RequestFactory
77
from myuw.models.myuw_notice import MyuwNotice
8-
from myuw.views.notice_admin import _get_datetime, _save_notice
9-
from datetime import datetime
8+
from myuw.views.notice_admin import _get_datetime, _get_html, _save_notice
109
from myuw.dao.myuw_notice import get_myuw_notices_for_user
1110
from myuw.test import get_request_with_user, get_request_with_date
12-
from myuw.test.dao.test_myuw_notice import get_datetime_with_tz
1311

12+
CONTENT = (
13+
"<p>Your Husky card is your key to efficiency on " +
14+
"campus and serves as your University ID, providing access " +
15+
"to eligible services such as dining plans, facilities, " +
16+
"transportation, UW libraries, and so much more.</p>\n<p><a " +
17+
"href=\"http://hfs.uw.edu/Husky-Card-Services/submit-a-photo" +
18+
"\">Submit your photo online</a>\nto be able to have your " +
19+
"Husky card printed and sent to you by mail. Students with " +
20+
"an international address should submit a photo online and " +
21+
"plan to pick up their Husky card on campus. Visit the <a " +
22+
"href=\"https://hfs.uw.edu/Husky-Card-Services/Operations-" +
23+
"Updates\" title=\"https://hfs.uw.edu/Husky-Card-Services/" +
24+
"Operations-Updates\">Husky Card Operations</a> page for " +
25+
"more information.\n</p>")
1426

15-
class TestNoticeAdmin(MyuwApiTest):
1627

17-
def test_get_datetime(self):
18-
string = ""
19-
self.assertIsNone(_get_datetime(string))
28+
class TestNoticeAdmin(MyuwApiTest):
2029

21-
string = "foobar"
22-
self.assertIsNone(_get_datetime(string))
30+
def _get_request(self, notice):
31+
return RequestFactory().post('', notice)
2332

33+
def test_get_datetime(self):
34+
self.assertIsNone(_get_datetime(""))
35+
self.assertIsNone(_get_datetime(None))
2436
string = "2018-05-08 15:28"
2537
self.assertEqual(str(_get_datetime(string)),
2638
"2018-05-08 15:28:00-07:00")
39+
string = "2018-05-08T15:28"
40+
self.assertEqual(str(_get_datetime(string)),
41+
"2018-05-08 15:28:00-07:00")
42+
string = "2018-05-08T15:28:00-07:00"
43+
self.assertEqual(str(_get_datetime(string)),
44+
"2018-05-08 15:28:00-07:00")
2745

28-
string = "2013-03-28 10:00:00+00:00"
29-
dt = get_datetime_with_tz(2013, 3, 28, 3)
30-
self.assertEqual(_get_datetime(string), dt)
46+
def test_get_html(self):
47+
self.assertIsNone(_get_html(None))
48+
self.assertEqual(_get_html(''), "")
49+
self.assertIsNotNone(_get_html(CONTENT))
50+
51+
@patch.object(MyuwNotice, 'save')
52+
def test_sql_error_save(self, mock):
53+
request = self._get_request(
54+
{
55+
'action': 'save',
56+
"title": "Test",
57+
"start_date": "2022-04-12 11:25",
58+
"end_date": "2022-04-15 11:25",
59+
"content": CONTENT,
60+
"notice_type": "Banner",
61+
"notice_category": "MyUWNotice",
62+
"is_critical": False,
63+
'affil': ['is_employee'],
64+
'target_group': ''
65+
})
66+
context = {}
67+
mock.side_effect = Exception('Error!')
68+
self.assertFalse(_save_notice(request, context))
69+
self.assertTrue(context['sql_error'])
3170

3271
def test_save_new_notice(self):
33-
rf = RequestFactory()
34-
request = rf.post('', {})
35-
72+
request = self._get_request({})
3673
saved = _save_notice(request, {})
3774
self.assertFalse(saved)
3875

39-
notice_context = {
40-
'action': 'save',
41-
'title': 'The Title ',
42-
'content': "<p>Foobar</p>",
43-
'affil': 'is_intl_stud',
44-
'campus': 'is_seattle',
45-
'start_date': '2018-05-25 12:00',
46-
'end_date': '2018-05-26 12:00',
47-
'notice_type': 'Foo',
48-
'notice_category': 'Bar',
49-
'target_group': ' uw_group '
50-
}
51-
request = rf.post('', notice_context)
76+
request = self._get_request(
77+
{
78+
'action': 'save',
79+
'title': 'The Title ',
80+
'content': "<p>Foobar</p>",
81+
'affil': 'is_intl_stud',
82+
'campus': 'is_seattle',
83+
'start_date': '2018-05-25 12:00',
84+
'end_date': '2018-05-26 12:00',
85+
'notice_type': 'Foo',
86+
'notice_category': 'Bar',
87+
'target_group': ' uw_group '
88+
})
5289
self.assertTrue(_save_notice(request, {}))
5390

5491
entries = MyuwNotice.objects.all()
@@ -63,84 +100,80 @@ def test_save_new_notice(self):
63100
self.assertEqual(entries[0].target_group, "uw_group")
64101

65102
# end before start
66-
notice_context = {
67-
'action': 'save',
68-
'title': 'The Title',
69-
'content': "<p>Foobar</p>",
70-
'start_date': "2018-05-25T12:05:00+00:00",
71-
'end_date': "2017-05-26T12:05:00+00:00",
72-
'notice_type': 'Foo',
73-
'notice_category': 'Bar'
74-
}
75-
request = rf.post('', notice_context)
103+
request = self._get_request(
104+
{
105+
'action': 'save',
106+
'title': 'The Title',
107+
'content': "<p>Foobar</p>",
108+
'start_date': "2018-05-25 12:05",
109+
'end_date': "2017-05-26 12:05",
110+
'notice_type': 'Foo',
111+
'notice_category': 'Bar'
112+
})
76113
context = {}
77114
self.assertFalse(_save_notice(request, context))
78115
self.assertTrue(context['date_error'])
79116

80117
# no start
81-
notice_context = {
82-
'action': 'save',
83-
'title': 'The Title',
84-
'content': "<p>Foobar</p>",
85-
'end_date': "2017-05-26T12:05:00+00:00",
86-
'notice_type': 'Foo',
87-
'notice_category': 'Bar'
88-
}
89-
request = rf.post('', notice_context)
118+
request = self._get_request(
119+
{
120+
'action': 'save',
121+
'title': 'The Title',
122+
'content': "<p>Foobar</p>",
123+
'end_date': "2017-05-26 12:05",
124+
'notice_type': 'Foo',
125+
'notice_category': 'Bar'
126+
})
90127
context = {}
91128
self.assertFalse(_save_notice(request, context))
92129
self.assertTrue(context['start_error'])
93130

94131
# Missing Attrs
95-
notice_context = {
96-
'action': 'save',
97-
}
98-
request = rf.post('', notice_context)
132+
request = self._get_request({'action': 'save', })
99133
context = {}
100134
self.assertFalse(_save_notice(request, context))
135+
print(context)
101136
self.assertTrue(context['start_error'])
102137
self.assertTrue(context['type_error'])
103138
self.assertTrue(context['category_error'])
104139
self.assertTrue(context['title_error'])
105140
self.assertTrue(context['content_error'])
106141

107-
def test_html_content(self):
108-
notice_context = {
109-
'action': 'save',
110-
'title': '<b>The</b> <p>Title</p>',
111-
'content': "<p>allowed tag</p> <script>not allowed</script>",
112-
'start_date': "2018-05-05T12:05:00+00:00",
113-
'end_date': "2018-05-26T12:05:00+00:00",
114-
'notice_type': 'Foo',
115-
'notice_category': 'Bar'
116-
}
117-
rf = RequestFactory()
118-
request = rf.post('', notice_context)
142+
def test_content_allowed_tags(self):
143+
request = self._get_request(
144+
{
145+
'action': 'save',
146+
'title': '<b>The</b> Title',
147+
'content': "<p>allowed tag</p> <span>not allowed</span>",
148+
'start_date': "2018-05-05 12:05",
149+
'end_date': "2018-05-26 12:05",
150+
'notice_type': 'Foo',
151+
'notice_category': 'Bar'
152+
})
119153
_save_notice(request, {})
120154

121155
request = get_request_with_date("2018-05-09")
122156
get_request_with_user('javerage', request)
123157
notices = get_myuw_notices_for_user(request)
124158

125-
self.assertEqual(notices[0].title, "<b>The</b> &lt;p&gt;"
126-
"Title&lt;/p&gt;")
159+
self.assertEqual(notices[0].title, "<b>The</b> Title")
127160

128-
self.assertEqual(notices[0].content, "<p>allowed tag</p> &lt;script"
129-
"&gt;not allowed&lt;/script&gt;")
161+
self.assertEqual(
162+
notices[0].content,
163+
"<p>allowed tag</p> <span>not allowed</span>")
130164

131-
def test_edit_notice(self):
165+
def test_target_group(self):
132166
notice_context = {
133167
'action': 'save',
134168
'title': 'Test Edit',
135169
'content': "Foo",
136-
'start_date': "2013-03-27T13:00:00+00:00",
137-
'end_date': "2013-05-06T23:13:00+00:00",
170+
'start_date': "2013-03-27 13:00",
171+
'end_date': "2013-05-06 23:13",
138172
'notice_type': 'Foo',
139173
'notice_category': 'Bar',
140174
'target_group': 'u_astratst_myuw_test-support-admin'
141175
}
142-
rf = RequestFactory()
143-
request = rf.post('', notice_context)
176+
request = self._get_request(notice_context)
144177
self.assertTrue(_save_notice(request, {}))
145178

146179
notice_context['action'] = 'edit'
@@ -150,7 +183,7 @@ def test_edit_notice(self):
150183
entries = MyuwNotice.objects.all()
151184
self.assertEqual(len(entries), 1)
152185

153-
request = rf.post('', notice_context)
186+
request = self._get_request(notice_context)
154187
self.assertTrue(_save_notice(request, {},
155188
notice_id=entries[0].id))
156189

0 commit comments

Comments
 (0)