uw_sws 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -11
- data/lib/uw_sws/version.rb +1 -1
- data/lib/uw_sws.rb +69 -98
- data/test/test_endpoints.rb +332 -0
- metadata +5 -7
- data/test/test_private_endpoints.rb +0 -161
- data/test/test_public_endpoints.rb +0 -201
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b43d286493de2d453829548668644a2e344b208f
|
4
|
+
data.tar.gz: 8d1ebf5d0e86047954ef2f68d2c3ce6466493266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96e279568721f916be1cf0f0dceacb25e8986326786119fc85b2e80255380f80ccb4063a1b68a3d1e985191b1e5788a9b260183b333693b061c2c0592aabf884
|
7
|
+
data.tar.gz: 695c902508566fdb5762ad8b5d68df71e7189f4984242e5f436ce4051baaafe10ecdfe8667ca46ab042d553b42717ab9d348fdfb0a2fc18783907e43f75169a6
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# UW Student Web Service
|
2
|
-
This implements
|
3
|
-
endpoints](https://wiki.cac.washington.edu/display/SWS/Student+Web+Service+Client+Home+Page).
|
2
|
+
This implements most of the [v5 UW Student Webservice
|
3
|
+
endpoints](https://wiki.cac.washington.edu/display/SWS/Student+Web+Service+Client+Home+Page). Each endpoint is querried for their json response and a hash is then returned. This gem has the capability to cache all web requests to assit with speedy development.
|
4
4
|
|
5
5
|
## USE
|
6
6
|
|
7
|
-
### Installation
|
7
|
+
### Installation
|
8
8
|
|
9
9
|
gem install uw_sws
|
10
10
|
|
@@ -12,28 +12,65 @@ endpoints](https://wiki.cac.washington.edu/display/SWS/Student+Web+Service+Clien
|
|
12
12
|
Basic example below gives you hash of term data for winter 2013
|
13
13
|
|
14
14
|
require 'uw_student_webservice'
|
15
|
-
service =
|
15
|
+
service = UwSws.new
|
16
16
|
term = service.term(2013, "winter")
|
17
17
|
|
18
18
|
Maybe you want all the Geology courses from 1985?
|
19
19
|
|
20
20
|
require 'uw_student_webservice'
|
21
|
-
service =
|
21
|
+
service = UwSws.new
|
22
22
|
courses = service(1985, "winter", curriculum: "GEOG")
|
23
23
|
|
24
24
|
For cases where you need to page through results you can check for the existance
|
25
25
|
of ``service.next`` and make follow up queries based on it's data.
|
26
26
|
|
27
27
|
require 'uw_student_webservice'
|
28
|
-
service =
|
28
|
+
service = UwSws.new
|
29
29
|
courses = service.courses(1985, "autumn", curriculum: "GEOG", size: 25)
|
30
30
|
puts service.next
|
31
31
|
|
32
|
-
For a full list of examples see
|
32
|
+
For a full list of examples see ``/test``
|
33
33
|
|
34
34
|
### Caching
|
35
35
|
|
36
|
-
If you pass ``use_cache: true`` as a parameter to ``
|
36
|
+
If you pass ``use_cache: true`` as a parameter to ``UwSws.new`` all web requests will be cached in your local file system. However, you will need to have a cache directory in the root of whatever projects you are using this gem in.
|
37
|
+
|
38
|
+
## Endpoint Implementation
|
39
|
+
All links below go to the official service documentation. The code block refers to it's implementation in this gem. See the tests for how to use all the supported endpoints.
|
40
|
+
|
41
|
+
``service = UwSws.new(...params...)``
|
42
|
+
|
43
|
+
#### Fully Supported
|
44
|
+
* [Campus](https://wiki.cac.washington.edu/display/SWS/Campus+Search+Resource+V5) ``service.campus``
|
45
|
+
* [College Search](https://wiki.cac.washington.edu/display/SWS/College+Search+Resource+V5) ``service.colleges``
|
46
|
+
* [Course](https://wiki.cac.washington.edu/display/SWS/Course+Resource+v5) ``service.course``
|
47
|
+
* [Course Search](https://wiki.cac.washington.edu/display/SWS/Course+Search+Resource+V5) ``service.courses``
|
48
|
+
* [Curriculumn Search](https://wiki.cac.washington.edu/display/SWS/Curriculum+Search+Resource+V5) ``service.curricula``
|
49
|
+
* [Department Search](https://wiki.cac.washington.edu/display/SWS/Department+Search+Resource+V5) ``service.departments``
|
50
|
+
* [Enrollment](https://wiki.cac.washington.edu/display/SWS/Enrollment+Resource+V5) ``service.enrollment``
|
51
|
+
* [Enrollment Search](https://wiki.cac.washington.edu/display/SWS/Enrollment+Search+Resource+V5) ``service.enrollments``
|
52
|
+
* [Personal Financial](https://wiki.cac.washington.edu/display/SWS/Personal+Financial+Resource+V5) ``service.finance``
|
53
|
+
* [Person](https://wiki.cac.washington.edu/display/SWS/Person+Resource+V5) ``service.person``
|
54
|
+
* [Person Search](https://wiki.cac.washington.edu/display/SWS/Person+Search+Resource+V5) ``service.people``
|
55
|
+
* [Registration](https://wiki.cac.washington.edu/display/SWS/Registration+Resource+V5) ``service.registration``
|
56
|
+
* [Registration Search](https://wiki.cac.washington.edu/display/SWS/Registration+Search+Resource+v5) ``service.registrations``
|
57
|
+
* [Section](https://wiki.cac.washington.edu/display/SWS/Section+Resource+V5) ``service.section``
|
58
|
+
* [Section Search](https://wiki.cac.washington.edu/display/SWS/Section+Search+Resource+v5) ``service.sections``
|
59
|
+
* [Term](https://wiki.cac.washington.edu/display/SWS/Term+Resource+V5) ``service.term``
|
60
|
+
* [Test Score](https://wiki.cac.washington.edu/display/SWS/Test+Score+Resource+V5) ``service.test_score``
|
61
|
+
|
62
|
+
#### Partially Supported (may or may not work)
|
63
|
+
* [Notice](https://wiki.cac.washington.edu/display/SWS/Notice+Resource+V5) ``service.notice``
|
64
|
+
|
65
|
+
#### Not implemented in this gem
|
66
|
+
Most of these are not implemented due to additional security requirements beyond a simple 509 cert. Requirements such as permissions in ASTRA or x-uw-act-as permissions passed in the header. Feel free fork and make a pull request with working tests if you have those permissions.
|
67
|
+
|
68
|
+
* [Degree Audit] (https://wiki.cac.washington.edu/display/SWS/SWS+v5+API) (all of them) under review
|
69
|
+
* [Change of Major](https://wiki.cac.washington.edu/display/SWS/Change+of+Major+Resource) extra security needed
|
70
|
+
* [Enrollment Majors ](https://wiki.cac.washington.edu/display/SWS/Enrollment+Majors) extra security needed
|
71
|
+
* [Resource List](https://wiki.cac.washington.edu/display/SWS/Resource+List+V5) not needed!
|
72
|
+
* [Section Status](https://wiki.cac.washington.edu/display/SWS/Section+Status+Resource+V5) extra security needed
|
73
|
+
* [Version List](https://wiki.cac.washington.edu/display/SWS/Version+List+Resource+v5) not needed!
|
37
74
|
|
38
75
|
|
39
76
|
## Development
|
@@ -45,7 +82,7 @@ If you pass ``use_cache: true`` as a parameter to ``UWStudentWebService.new`` al
|
|
45
82
|
bundle install
|
46
83
|
|
47
84
|
### Setup and Tests
|
48
|
-
|
85
|
+
Change the ``cache`` symlink to point to a valid path or create a directory for it like below. As you can see in ``/test`` you will need to also provide the full path to your 509 cert and key before running ``rake``.
|
49
86
|
|
50
87
|
rm cache
|
51
88
|
mkdir cache
|
@@ -59,5 +96,8 @@ Make sure to delete /test/test_private_endpoints.rb if you are not authorized at
|
|
59
96
|
4. Push to the branch (`git push origin my-new-feature`)
|
60
97
|
5. Create new Pull Request
|
61
98
|
|
62
|
-
|
63
|
-
|
99
|
+
### Changes Since < 2.0.0
|
100
|
+
* v4 is no longer used, all queries are now against v5
|
101
|
+
* no more public endpoints, all queries now require a cert
|
102
|
+
* Endpoints that ended with _search have been changed to their plural form (person_search to people)
|
103
|
+
* A few new endpoints were added, see list above for whats supported
|
data/lib/uw_sws/version.rb
CHANGED
data/lib/uw_sws.rb
CHANGED
@@ -6,71 +6,69 @@ class UwSws
|
|
6
6
|
attr_reader :last, :next
|
7
7
|
|
8
8
|
def initialize(throw_404: true, logger: Logger.new(STDOUT),
|
9
|
-
use_cache: true, cert: "", key: "", throw_HEPPS: true
|
10
|
-
|
11
|
-
@
|
9
|
+
use_cache: true, cert: "", key: "", throw_HEPPS: true,
|
10
|
+
base: "https://ws.admin.washington.edu/student/v5/")
|
11
|
+
@base = base
|
12
12
|
@last = nil
|
13
13
|
@next = ""
|
14
14
|
@use_cache = use_cache
|
15
15
|
@logger = logger
|
16
16
|
@throw_404 = throw_404
|
17
17
|
@throw_HEPPS = throw_HEPPS
|
18
|
-
@private_endpoint = false
|
19
18
|
load_config(cert, key)
|
20
19
|
end
|
21
20
|
|
22
21
|
def campus
|
23
|
-
parse
|
22
|
+
parse "campus.json"
|
24
23
|
end
|
25
24
|
|
26
25
|
def colleges(campus)
|
27
|
-
data = parse
|
26
|
+
data = parse "college.json?campus_short_name=#{campus}"
|
28
27
|
|
29
28
|
data["Colleges"]
|
30
29
|
end
|
31
30
|
|
32
31
|
def departments(college)
|
33
|
-
fix_param
|
34
|
-
data = parse
|
32
|
+
fix_param college
|
33
|
+
data = parse "department.json?college_abbreviation=#{college}"
|
35
34
|
|
36
35
|
data["Departments"]
|
37
36
|
end
|
38
37
|
|
39
38
|
def curricula(year, quarter, department: "", count: 0)
|
40
|
-
fix_param
|
41
|
-
data = parse("
|
39
|
+
fix_param department
|
40
|
+
data = parse("curriculum.json?year=#{year}&quarter=#{quarter}"\
|
42
41
|
"&future_terms=#{count}&department_abbreviation=#{department}")
|
43
42
|
|
44
43
|
data["Curricula"]
|
45
44
|
end
|
46
45
|
|
47
|
-
def course(year, quarter, curriculum, number
|
48
|
-
fix_param
|
49
|
-
data = parse
|
50
|
-
"#{curriculum},#{number}.json")
|
46
|
+
def course(year, quarter, curriculum, number)
|
47
|
+
fix_param curriculum
|
48
|
+
data = parse "course/#{year},#{quarter},#{curriculum},#{number}.json"
|
51
49
|
data
|
52
50
|
end
|
53
51
|
|
54
52
|
def term(year, quarter)
|
55
|
-
parse
|
53
|
+
parse "term/#{year},#{quarter}.json"
|
56
54
|
end
|
57
55
|
|
58
56
|
def term_current
|
59
|
-
parse
|
57
|
+
parse "term/current.json"
|
60
58
|
end
|
61
59
|
|
62
60
|
def term_next
|
63
|
-
parse
|
61
|
+
parse "term/next.json"
|
64
62
|
end
|
65
63
|
|
66
64
|
def term_previous
|
67
|
-
parse
|
65
|
+
parse "term/previous.json"
|
68
66
|
end
|
69
67
|
|
70
68
|
def sections(year, curriculum: "", instructor: "", count: 0, quarter: "",
|
71
|
-
course_num: ""
|
72
|
-
fix_param
|
73
|
-
data = parse("
|
69
|
+
course_num: "")
|
70
|
+
fix_param curriculum
|
71
|
+
data = parse("section.json?year=#{year}"\
|
74
72
|
"&quarter=#{quarter}&curriculum_abbreviation=#{curriculum}"\
|
75
73
|
"&future_terms=#{count}&course_number=#{course_num}"\
|
76
74
|
"®_id=#{instructor}")
|
@@ -81,11 +79,10 @@ class UwSws
|
|
81
79
|
def courses(year, quarter, curriculum: "", course: "", has_sections: "",
|
82
80
|
size: 100, start: "", count: "", get_next: false)
|
83
81
|
if get_next
|
84
|
-
|
85
|
-
data = parse("#{endpoint}#{url}")
|
82
|
+
data = parse @next.sub("/student/v5/", "")
|
86
83
|
else
|
87
|
-
fix_param
|
88
|
-
data = parse("
|
84
|
+
fix_param curriculum
|
85
|
+
data = parse("course.json?&year=#{year}&quarter=#{quarter}"\
|
89
86
|
"&curriculum_abbreviation=#{curriculum}&"\
|
90
87
|
"course_number=#{course}&page_size=#{size}"\
|
91
88
|
"&page_start=#{start}"\
|
@@ -96,79 +93,51 @@ class UwSws
|
|
96
93
|
data["Courses"]
|
97
94
|
end
|
98
95
|
|
99
|
-
def section(year, quarter, curriculum, number, id
|
100
|
-
fix_param
|
101
|
-
|
102
|
-
"#{curriculum},#{number}/#{id}.json")
|
103
|
-
|
104
|
-
data
|
96
|
+
def section(year, quarter, curriculum, number, id)
|
97
|
+
fix_param curriculum
|
98
|
+
parse "course/#{year},#{quarter},#{curriculum},#{number}/#{id}.json"
|
105
99
|
end
|
106
100
|
|
107
|
-
#
|
108
|
-
# these are for UW stff/faculty only, authentcation required
|
109
|
-
# other methods that have is_private: as a param option can call
|
110
|
-
# the private endpoint as well as the public endpoint
|
111
|
-
#
|
112
|
-
|
113
101
|
def test_score(type, regid)
|
114
|
-
parse
|
115
|
-
end
|
116
|
-
|
117
|
-
def enrollment_search(regid, verbose: "")
|
118
|
-
data = parse("#{endpoint(true)}enrollment.json?reg_id=#{regid}"\
|
119
|
-
"&verbose=#{verbose}")
|
120
|
-
|
121
|
-
verbose.empty? ? data["EnrollmentLinks"] : data["Enrollments"]
|
102
|
+
parse "testscore/#{type},#{regid}.json"
|
122
103
|
end
|
123
104
|
|
124
105
|
def enrollment(year, quarter, regid, verbose: "")
|
125
|
-
parse
|
126
|
-
"?verbose=#{verbose}")
|
106
|
+
parse "enrollment/#{year},#{quarter},#{regid}.json?verbose=#{verbose}"
|
127
107
|
end
|
128
108
|
|
129
|
-
def
|
130
|
-
|
131
|
-
|
132
|
-
parse("#{endpoint(true)}course/#{year},#{quarter},#{curric}," \
|
133
|
-
"#{course}/#{id}/status.json")
|
134
|
-
end
|
109
|
+
def enrollments(regid, verbose: "")
|
110
|
+
data = parse "enrollment.json?reg_id=#{regid}&verbose=#{verbose}"
|
135
111
|
|
136
|
-
|
137
|
-
parse("#{endpoint(true)}term/#{year},#{quarter}.json")
|
138
|
-
end
|
139
|
-
|
140
|
-
def term_current_private
|
141
|
-
parse("#{endpoint(true)}term/current.json")
|
112
|
+
verbose.empty? ? data["EnrollmentLinks"] : data["Enrollments"]
|
142
113
|
end
|
143
114
|
|
144
|
-
def
|
145
|
-
|
146
|
-
end
|
115
|
+
def section_status(year, quarter, curric, course, id)
|
116
|
+
fix_param curric
|
147
117
|
|
148
|
-
|
149
|
-
parse("#{endpoint(true)}term/previous.json")
|
118
|
+
parse "course/#{year},#{quarter},#{curric},#{course}/#{id}/status.json"
|
150
119
|
end
|
151
120
|
|
152
121
|
def person(regid)
|
153
|
-
parse
|
122
|
+
parse "person/#{regid}.json"
|
154
123
|
end
|
155
124
|
|
156
|
-
def
|
157
|
-
parse
|
125
|
+
def people(type, id)
|
126
|
+
parse "person.json?#{type}=#{id}"
|
158
127
|
end
|
159
128
|
|
160
129
|
def registration(year, quarter, curric, course, id, reg_id, dup_code = "")
|
161
|
-
fix_param
|
130
|
+
fix_param curric
|
162
131
|
|
163
|
-
parse("
|
132
|
+
parse("registration/#{year},#{quarter},#{curric}," \
|
164
133
|
"#{course},#{id},#{reg_id},#{dup_code}.json")
|
165
134
|
end
|
166
135
|
|
167
|
-
def
|
136
|
+
def registrations(year, quarter, curriculum: "", course: "",
|
168
137
|
section: "", reg_id: "", active: "",
|
169
138
|
reg_id_instructor: "")
|
170
|
-
fix_param
|
171
|
-
data = parse("
|
139
|
+
fix_param curriculum
|
140
|
+
data = parse("registration.json?year=#{year}&"\
|
172
141
|
"quarter=#{quarter}&curriculum_abbreviation=#{curriculum}&"\
|
173
142
|
"course_number=#{course}§ion_id=#{section}&"\
|
174
143
|
"reg_id=#{reg_id}&is_active=#{active}&"\
|
@@ -177,6 +146,18 @@ class UwSws
|
|
177
146
|
data["Registrations"]
|
178
147
|
end
|
179
148
|
|
149
|
+
def notice(regid)
|
150
|
+
parse "notice/#{regid}.json"
|
151
|
+
end
|
152
|
+
|
153
|
+
def change_of_major(year, quarter, regid)
|
154
|
+
parse "enrollment/#{year},#{quarter},#{regid}/major.json"
|
155
|
+
end
|
156
|
+
|
157
|
+
def finance(regid)
|
158
|
+
parse "person/#{regid}/financial.json"
|
159
|
+
end
|
160
|
+
|
180
161
|
private
|
181
162
|
|
182
163
|
def default_logger
|
@@ -194,18 +175,12 @@ class UwSws
|
|
194
175
|
end
|
195
176
|
end
|
196
177
|
|
197
|
-
def endpoint(is_private = false)
|
198
|
-
@private_endpoint = is_private
|
199
|
-
|
200
|
-
is_private ? @base_private : @base
|
201
|
-
end
|
202
|
-
|
203
178
|
def parse(url)
|
204
|
-
data = request
|
179
|
+
data = request "#{@base}#{url}"
|
205
180
|
return nil unless !data.nil?
|
206
|
-
data = clean
|
181
|
+
data = clean data
|
207
182
|
|
208
|
-
@last = JSON.parse
|
183
|
+
@last = JSON.parse data
|
209
184
|
@logger.debug "fetched - #{@last}"
|
210
185
|
@next = @last["Next"].nil? ? "" : @last["Next"]["Href"]
|
211
186
|
|
@@ -241,16 +216,12 @@ class UwSws
|
|
241
216
|
data
|
242
217
|
end
|
243
218
|
|
244
|
-
def restful_client(url
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
log: @logger)
|
251
|
-
else
|
252
|
-
RestClient::Resource.new(url, log: @logger)
|
253
|
-
end
|
219
|
+
def restful_client(url)
|
220
|
+
RestClient::Resource.new(
|
221
|
+
url,
|
222
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(@cert_file),
|
223
|
+
ssl_client_key: OpenSSL::PKey::RSA.new(@key_file),
|
224
|
+
log: @logger)
|
254
225
|
end
|
255
226
|
|
256
227
|
def get_cache(file)
|
@@ -271,10 +242,10 @@ class UwSws
|
|
271
242
|
|
272
243
|
def load_config(cert, key)
|
273
244
|
if ! (cert.empty? && key.empty?)
|
274
|
-
does_exist?
|
275
|
-
@cert_file = File.read
|
276
|
-
does_exist?
|
277
|
-
@key_file = File.read
|
245
|
+
does_exist? cert
|
246
|
+
@cert_file = File.read cert
|
247
|
+
does_exist? key
|
248
|
+
@key_file = File.read key
|
278
249
|
@logger.debug "loaded cert and key files"
|
279
250
|
end
|
280
251
|
|
@@ -282,7 +253,7 @@ class UwSws
|
|
282
253
|
end
|
283
254
|
|
284
255
|
def does_exist?(file)
|
285
|
-
raise "Could not find #{file}" unless File.exist?
|
256
|
+
raise "Could not find #{file}" unless File.exist? file
|
286
257
|
end
|
287
258
|
|
288
259
|
def clean_bools(data)
|
@@ -297,7 +268,7 @@ class UwSws
|
|
297
268
|
end
|
298
269
|
|
299
270
|
def clean(data)
|
300
|
-
data = clean_spaces
|
301
|
-
data = clean_bools
|
271
|
+
data = clean_spaces data
|
272
|
+
data = clean_bools data
|
302
273
|
end
|
303
274
|
end
|
@@ -0,0 +1,332 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "json"
|
3
|
+
require "logger"
|
4
|
+
require_relative "../lib/uw_sws"
|
5
|
+
|
6
|
+
describe UwSws do
|
7
|
+
before do
|
8
|
+
log = Logger.new("log.txt")
|
9
|
+
log.level = Logger::FATAL
|
10
|
+
|
11
|
+
# cert and key are required
|
12
|
+
# do not explicity set URL if you want to make sure to use v5 production
|
13
|
+
cert = "/home/marc/.keys/milesm.bschool.pem"
|
14
|
+
key = "/home/marc/.keys/ItsAllGood.key"
|
15
|
+
url = "https://ucswseval1.cac.washington.edu/student/v5/"
|
16
|
+
@regid = "DB79E7927ECA11D694790004AC494FFE"
|
17
|
+
@uw = UwSws.new(cert: cert, key: key, throw_HEPPS: false,
|
18
|
+
logger: log, use_cache: true, base: url)
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when getting test scores " do
|
22
|
+
it "it must not be nil" do
|
23
|
+
@uw.test_score("SAT", "9136CCB8F66711D5BE060004AC494FFE")
|
24
|
+
@uw.last.wont_be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "when getting term " do
|
29
|
+
it "it must not be nil" do
|
30
|
+
@uw.term(2013, :summer)
|
31
|
+
@uw.last.wont_be_nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "when getting terms " do
|
36
|
+
it "must respond with a FirstDay" do
|
37
|
+
data = @uw.term(2013, :summer)
|
38
|
+
data["FirstDay"].wont_be_nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "when getting section status " do
|
43
|
+
it "it must not be nil" do
|
44
|
+
# this endpoint requires extra permissions that I don't have
|
45
|
+
# @uw.section_status(2009, "winter", "MUSAP", 218, "A")
|
46
|
+
# @uw.last.wont_be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "when getting sections " do
|
51
|
+
it "must return at least 5 of them" do
|
52
|
+
@uw.sections(1999, curriculum: "OPMGT").size.must_be :>, 5
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "when getting a course " do
|
57
|
+
it "must return course data" do
|
58
|
+
data = @uw.course(1992, :autumn, "CSE", 142)
|
59
|
+
data["FirstEffectiveTerm"].wont_be_empty
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "when getting a person " do
|
64
|
+
it "must not be nil" do
|
65
|
+
@uw.person(@regid)
|
66
|
+
@uw.last.wont_be_nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "when doing a search for a person " do
|
71
|
+
it "each must not be nil" do
|
72
|
+
@uw.people("reg_id", @regid)
|
73
|
+
@uw.last.wont_be_nil
|
74
|
+
@uw.people("net_id", "milesm")
|
75
|
+
@uw.last.wont_be_nil
|
76
|
+
@uw.people("student_number", "0242267")
|
77
|
+
@uw.last.wont_be_nil
|
78
|
+
@uw.people("employee_id", "864004999")
|
79
|
+
@uw.last.wont_be_nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "when doing an enrollment search " do
|
84
|
+
it "it must equal 2" do
|
85
|
+
@uw.enrollments(@regid).size.must_equal(2)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "when doing a verbose enrollment search " do
|
90
|
+
it "it must have 2" do
|
91
|
+
@uw.enrollments(@regid, verbose: "on").size.must_equal(2)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "when getting a grade within an enrollment " do
|
96
|
+
it "it must equal 3.9" do
|
97
|
+
data = @uw.enrollment(2002, :summer, @regid, verbose: "on")
|
98
|
+
data["Registrations"][0]["Grade"].must_equal("3.9")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# NOTE ABOUT REGISTRATION SEARCHES
|
104
|
+
# THEY ONLY WORK WITH CURRENT TERMS....
|
105
|
+
# these tests will fail unless the params are in the present year/quarter
|
106
|
+
#
|
107
|
+
describe "when getting a registration " do
|
108
|
+
it "it must not be nil" do
|
109
|
+
# since registrations are not available for prev terms
|
110
|
+
# make this a current year and valid regid
|
111
|
+
#
|
112
|
+
#term = @uw.term_current
|
113
|
+
#@uw.registration(term["Year"], term["Quarter"], "CSE", 142, "A",
|
114
|
+
# "6ADA93ABA771476481FE44FC086C74DA")
|
115
|
+
#@uw.last.wont_be_nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "when searching for active course registrations " do
|
120
|
+
it "it must be greater than 100" do
|
121
|
+
term = @uw.term_current
|
122
|
+
data = @uw.registrations(term["Year"], term["Quarter"],
|
123
|
+
curriculum: "CSE", course: 142,
|
124
|
+
section: "A", active: "on")
|
125
|
+
data.size.must_be :>, 100
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "when searching for course registrations " do
|
130
|
+
it "it must be greater than 200" do
|
131
|
+
term = @uw.term_current
|
132
|
+
data = @uw.registrations(term["Year"], term["Quarter"],
|
133
|
+
curriculum: "CSE", course: 142,
|
134
|
+
section: "A")
|
135
|
+
data.size.must_be :>, 200
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "when searching for person registrations " do
|
140
|
+
it "it must have more than 1" do
|
141
|
+
# registrations are only available for current terms
|
142
|
+
term = @uw.term_current
|
143
|
+
data = @uw.registrations(term["Year"], term["Quarter"],
|
144
|
+
curriculum: "CSE", course: 142,
|
145
|
+
section: "A", active: "on")
|
146
|
+
|
147
|
+
result = @uw.registrations(term["Year"], term["Quarter"],
|
148
|
+
reg_id: data[0]["RegID"])
|
149
|
+
result.size.must_be :>, 0
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
describe "when getting campus list " do
|
155
|
+
it "must return at least 3 of them" do
|
156
|
+
data = @uw.campus
|
157
|
+
campus = data["Campuses"]
|
158
|
+
campus.size.must_be :>, 2
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "when checking last response " do
|
163
|
+
it "it must not be nil" do
|
164
|
+
@uw.term(1921, :winter)
|
165
|
+
@uw.last.wont_be_nil
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
describe "when asked for the current, next and previous terms " do
|
171
|
+
it "each must respond with a FirstDay" do
|
172
|
+
@uw.term_current["FirstDay"].wont_be_nil
|
173
|
+
@uw.term_next["FirstDay"].wont_be_nil
|
174
|
+
@uw.term_previous["FirstDay"].wont_be_nil
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "when asked for colleges " do
|
179
|
+
it "must return at least 10 of them" do
|
180
|
+
@uw.colleges("SEATTLE").size.must_be :>, 9
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe "when asked for departments " do
|
185
|
+
it "must return at least 12 of them" do
|
186
|
+
@uw.departments("A & S").size.must_be :>, 11
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "when asked for curriculum " do
|
191
|
+
it "must return at least 5 of them" do
|
192
|
+
@uw.curricula(1999, :winter, department: "B A").size.must_be :>, 5
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe "when asked for all curricula in a year " do
|
197
|
+
it "must return at least 100 of them" do
|
198
|
+
# note...this can timeout if too many future terms are requested
|
199
|
+
@uw.curricula(1990, :autumn).size.must_be :>, 99
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# section searches
|
204
|
+
# instructor or curriculum are required
|
205
|
+
# year is also required
|
206
|
+
# with no quarter you get all quarters
|
207
|
+
# quarter is required if searching by instructor
|
208
|
+
describe "when asked for sections " do
|
209
|
+
it "must return at least 5 of them" do
|
210
|
+
@uw.sections(1999, curriculum: "OPMGT").size.must_be :>, 5
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "when asked for sections in a quarter " do
|
215
|
+
it "must return at least 5 of them" do
|
216
|
+
@uw.sections(2000, curriculum: "engl", quarter: :autumn)
|
217
|
+
.size.must_be :>, 5
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe "when asked for future sections " do
|
222
|
+
it "must return at 898 of them" do
|
223
|
+
@uw.sections(2000, curriculum: "engl", quarter: :autumn, count: 3)
|
224
|
+
.size.must_equal(898)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
describe "when asked for sections in a course " do
|
229
|
+
it "must return at least 2 of them" do
|
230
|
+
@uw.sections(1992, curriculum: "OPMGT", quarter: :winter,
|
231
|
+
course_num: 301).size.must_be :>, 2
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "when asked for sections an instructor is teaching " do
|
236
|
+
it "must return at least 1 of them" do
|
237
|
+
@uw.sections(2009, instructor: "78BE067C6A7D11D5A4AE0004AC494FFE",
|
238
|
+
quarter: :summer).size.must_be :>, 0
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "when asked for section with a HEPPS error " do
|
243
|
+
it "must respond with error 500" do
|
244
|
+
@uw.section(2013, :autumn, "PB AF", 521, "A").must_be_nil
|
245
|
+
end
|
246
|
+
end
|
247
|
+
# course searches
|
248
|
+
# curric is not needed if searching by course number
|
249
|
+
# future terms must be 0-2, but, must be zero if exclude course w/o section
|
250
|
+
# make sure to page larger results using page_size and page_start
|
251
|
+
# while !@uw.next.nil?
|
252
|
+
# get result, append, next
|
253
|
+
# the following query string attributes dont seem to work
|
254
|
+
# course_title_starts, course_title_contains,
|
255
|
+
|
256
|
+
describe "when asked for courses in a curriculum " do
|
257
|
+
it "must return at least 10 of them" do
|
258
|
+
@uw.courses(1985, :winter, curriculum: "GEOG").size.must_be :>, 9
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "when asked for courses having number = 100 " do
|
263
|
+
it "must return at least 10 of them" do
|
264
|
+
@uw.courses(1985, :winter, course: 100).size.must_be :>, 9
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
describe "when asked for courses having number = 100 with future terms " do
|
269
|
+
it "must return at least 10 of them" do
|
270
|
+
@uw.courses(2013, :winter, course: 100, count: 2).size.must_be :>, 9
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
describe "when asked for courses in a curriculum having sections " do
|
275
|
+
it "must return at least 5 of them" do
|
276
|
+
@uw.courses(2005, :autumn, curriculum: "ENGL", has_sections: "on")
|
277
|
+
.size.must_be :>, 5
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe "when paging courses in a curriculum " do
|
282
|
+
it "must have a url that indicates next page" do
|
283
|
+
# this particular curric has 107 courses
|
284
|
+
# ideally, you would want to join results until .next is empty
|
285
|
+
@uw.courses(1985, :autumn, curriculum: "GEOG", size: 25)
|
286
|
+
@uw.next.wont_be_empty
|
287
|
+
@uw.courses(nil, nil, get_next: true).size.must_equal(25)
|
288
|
+
@uw.courses(nil, nil, get_next: true).size.must_equal(25)
|
289
|
+
@uw.courses(nil, nil, get_next: true).size.must_equal(25)
|
290
|
+
@uw.courses(nil, nil, get_next: true).size.must_equal(7)
|
291
|
+
@uw.next.must_be_empty
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe "when asked for a section " do
|
296
|
+
it "must have 8 enrolled" do
|
297
|
+
# who were these first 8 to take this infamous course?
|
298
|
+
# I took it in 2002...it was C++ then
|
299
|
+
data = @uw.section(1992, :autumn, "CSE", 142, "AA")
|
300
|
+
data["CurrentEnrollment"].must_equal(8)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe "when asked to test a section with a zero start room number " do
|
305
|
+
it "must return without error" do
|
306
|
+
@uw.section(2010, "spring", "ARTS", 150, "A").wont_be_nil
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe "when getting notices " do
|
311
|
+
it "it must not be nil" do
|
312
|
+
term = @uw.term_current
|
313
|
+
data = @uw.registrations(term["Year"], term["Quarter"],
|
314
|
+
curriculum: "CSE", course: 142,
|
315
|
+
section: "A", active: "on")
|
316
|
+
|
317
|
+
# the following generates 500 errors...
|
318
|
+
#puts @uw.notice data[0]["RegID"]
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
describe "when getting financial info " do
|
323
|
+
it "it must not be nil" do
|
324
|
+
term = @uw.term_current
|
325
|
+
data = @uw.registrations(term["Year"], term["Quarter"],
|
326
|
+
curriculum: "CSE", course: 142,
|
327
|
+
section: "A", active: "on")
|
328
|
+
result = @uw.finance data[0]["RegID"]
|
329
|
+
result["Person"].wont_be_nil
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uw_sws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nogbit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -66,8 +66,7 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- lib/uw_sws.rb
|
68
68
|
- lib/uw_sws/version.rb
|
69
|
-
- test/
|
70
|
-
- test/test_public_endpoints.rb
|
69
|
+
- test/test_endpoints.rb
|
71
70
|
- uw_sws.gemspec
|
72
71
|
homepage: https://github.com/UWFosterIT/uwsws
|
73
72
|
licenses:
|
@@ -89,10 +88,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
88
|
version: '0'
|
90
89
|
requirements: []
|
91
90
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
91
|
+
rubygems_version: 2.3.0
|
93
92
|
signing_key:
|
94
93
|
specification_version: 4
|
95
94
|
summary: Wraps most of the rest endpoints
|
96
95
|
test_files:
|
97
|
-
- test/
|
98
|
-
- test/test_public_endpoints.rb
|
96
|
+
- test/test_endpoints.rb
|
@@ -1,161 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require "json"
|
3
|
-
require "logger"
|
4
|
-
require_relative "../lib/uw_sws"
|
5
|
-
|
6
|
-
describe UwSws do
|
7
|
-
before do
|
8
|
-
log = Logger.new("log.txt")
|
9
|
-
log.level = Logger::FATAL
|
10
|
-
|
11
|
-
cert = "/home/marc/.keys/milesm.bschool.pem"
|
12
|
-
key = "/home/marc/.keys/ItsAllGood.key"
|
13
|
-
@regid = "DB79E7927ECA11D694790004AC494FFE"
|
14
|
-
@uw = UwSws.new(cert: cert, key: key, logger: log, use_cache: true)
|
15
|
-
end
|
16
|
-
|
17
|
-
#
|
18
|
-
# all of these test are for private endpoints
|
19
|
-
# they require that you initialize the service with a cert
|
20
|
-
# and a key file as they are required for all of these tests.
|
21
|
-
# Simply delete this test if you want your rake to pass and are
|
22
|
-
# not using these endpoints
|
23
|
-
#
|
24
|
-
describe "when getting test score private endpoint " do
|
25
|
-
it "it must not be nil" do
|
26
|
-
@uw.test_score("SAT", "9136CCB8F66711D5BE060004AC494FFE")
|
27
|
-
@uw.last.wont_be_nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "when getting term private endpoint " do
|
32
|
-
it "it must not be nil" do
|
33
|
-
@uw.term_private(2013, "autumn")
|
34
|
-
@uw.last.wont_be_nil
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "when asked for the current, next and previous term private " do
|
39
|
-
it "each must respond with a FirstDay" do
|
40
|
-
@uw.term_current_private["FirstDay"].wont_be_nil
|
41
|
-
@uw.term_next_private["FirstDay"].wont_be_nil
|
42
|
-
@uw.term_previous_private["FirstDay"].wont_be_nil
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "when getting section status private endpoint " do
|
47
|
-
it "it must not be nil" do
|
48
|
-
# this endpoint requires extra permissions that I dont have
|
49
|
-
# @uw.section_status(2009, "winter", "MUSAP", 218, "A")
|
50
|
-
# @uw.last.wont_be_nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "when getting sections private endpoint " do
|
55
|
-
it "must return at least 5 of them" do
|
56
|
-
@uw.sections(1999, curriculum: "OPMGT", is_private: true)
|
57
|
-
.size.must_be :>, 5
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "when getting a section private endpoint " do
|
62
|
-
it "must have 8 enrolled" do
|
63
|
-
data = @uw.section(1992, "autumn", "CSE", 142, "AA", is_private: true)
|
64
|
-
data["CurrentEnrollment"].must_equal("8")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "when getting a course private endpoint " do
|
69
|
-
it "must return course data" do
|
70
|
-
data = @uw.course(1992, "autumn", "CSE", 142, is_private: true)
|
71
|
-
data["FirstEffectiveTerm"].wont_be_empty
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "when getting a person private endpoint " do
|
76
|
-
it "must not be nil" do
|
77
|
-
@uw.person(@regid)
|
78
|
-
@uw.last.wont_be_nil
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "when doing a search for a person private endpoint " do
|
83
|
-
it "each must not be nil" do
|
84
|
-
@uw.person_search("reg_id", @regid)
|
85
|
-
@uw.last.wont_be_nil
|
86
|
-
@uw.person_search("net_id", "milesm")
|
87
|
-
@uw.last.wont_be_nil
|
88
|
-
@uw.person_search("student_number", "0242267")
|
89
|
-
@uw.last.wont_be_nil
|
90
|
-
@uw.person_search("employee_id", "864004999")
|
91
|
-
@uw.last.wont_be_nil
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe "when doing an enrollment search private endpoint " do
|
96
|
-
it "it must equal 2" do
|
97
|
-
@uw.enrollment_search(@regid).size.must_equal(2)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe "when doing a verbose enrollment search private endpoint " do
|
102
|
-
it "it must have 2" do
|
103
|
-
@uw.enrollment_search(@regid, verbose: "on").size.must_equal(2)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "when getting a grade within an enrollment private endpoint " do
|
108
|
-
it "it must equal 3.9" do
|
109
|
-
data = @uw.enrollment(2002, "summer", @regid, verbose: "on")
|
110
|
-
data["Registrations"][0]["Grade"].must_equal("3.9")
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
#
|
115
|
-
# NOTE ABOUT REGISTRATION SEARCHES
|
116
|
-
# THEY ONLY WORK WITH CURRENT TERMS....
|
117
|
-
# these tests will fail unless the params are in the present year/quarter
|
118
|
-
#
|
119
|
-
describe "when getting a registration private endpoint " do
|
120
|
-
it "it must not be nil" do
|
121
|
-
# since registrations are not available for prev terms
|
122
|
-
# make this a current year and valid regid
|
123
|
-
#
|
124
|
-
#term = @uw.term_current
|
125
|
-
#@uw.registration(term["Year"], term["Quarter"], "CSE", 142, "A",
|
126
|
-
# "6ADA93ABA771476481FE44FC086C74DA")
|
127
|
-
#@uw.last.wont_be_nil
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe "when searching for active course registrations private endpoint " do
|
132
|
-
it "it must be greater than 100" do
|
133
|
-
term = @uw.term_current
|
134
|
-
data = @uw.registration_search(term["Year"], term["Quarter"],
|
135
|
-
curriculum: "CSE", course: 142,
|
136
|
-
section: "A", active: "on")
|
137
|
-
data.size.must_be :>, 100
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe "when searching for course registrations private endpoint " do
|
142
|
-
it "it must be greater than 200" do
|
143
|
-
term = @uw.term_current
|
144
|
-
data = @uw.registration_search(term["Year"], term["Quarter"],
|
145
|
-
curriculum: "CSE", course: 142,
|
146
|
-
section: "A")
|
147
|
-
data.size.must_be :>, 200
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
describe "when searching for person registrations private endpoint " do
|
152
|
-
it "it must have more than 10" do
|
153
|
-
# since registrations are not available for prev terms
|
154
|
-
# make this a current year and valid regid
|
155
|
-
#
|
156
|
-
#@uw.registration_search(2013, "autumn",
|
157
|
-
# reg_id: "6ADA93ABA771476481FE44FC086C74DA")
|
158
|
-
# .size.must_be :>, 10
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
@@ -1,201 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require "json"
|
3
|
-
require "logger"
|
4
|
-
require_relative "../lib/uw_sws"
|
5
|
-
|
6
|
-
describe UwSws do
|
7
|
-
before do
|
8
|
-
log = Logger.new("log.txt")
|
9
|
-
log.level = Logger::FATAL
|
10
|
-
@uw = UwSws.new(logger: log, use_cache: true, throw_HEPPS: false)
|
11
|
-
end
|
12
|
-
|
13
|
-
def terms
|
14
|
-
[:winter, :spring, :summer, :autumn]
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "when asked for campus " do
|
18
|
-
it "must return at least 3 of them" do
|
19
|
-
data = @uw.campus
|
20
|
-
campus = data["Campuses"]
|
21
|
-
campus.size.must_be :>, 2
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "web checking last RESTful respone " do
|
26
|
-
it "it must not be nil" do
|
27
|
-
@uw.term(1921, terms[0])
|
28
|
-
@uw.last.wont_be_nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "web asked for terms " do
|
33
|
-
it "must respond with a FirstDay" do
|
34
|
-
data = @uw.term(2013, terms[2])
|
35
|
-
data["FirstDay"].wont_be_nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "when asked for the current, next and previous terms " do
|
40
|
-
it "each must respond with a FirstDay" do
|
41
|
-
@uw.term_current["FirstDay"].wont_be_nil
|
42
|
-
@uw.term_next["FirstDay"].wont_be_nil
|
43
|
-
@uw.term_previous["FirstDay"].wont_be_nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "when asked for colleges " do
|
48
|
-
it "must return at least 10 of them" do
|
49
|
-
@uw.colleges("SEATTLE").size.must_be :>, 9
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "when asked for departments " do
|
54
|
-
it "must return at least 12 of them" do
|
55
|
-
@uw.departments("A & S").size.must_be :>, 11
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "when asked for curriculumn " do
|
60
|
-
it "must return at least 5 of them" do
|
61
|
-
@uw.curricula(1999, terms[0], department: "B A").size.must_be :>, 5
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "when asked for all curricula in a year " do
|
66
|
-
it "must return at least 100 of them" do
|
67
|
-
# note...this can timeout if too many future terms are requested
|
68
|
-
@uw.curricula(1990, terms[3]).size.must_be :>, 99
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# section searches
|
73
|
-
# instructor or curriculumn are required
|
74
|
-
# year is also required
|
75
|
-
# with no quarter you get all quarters
|
76
|
-
# quarter is required if searching by instructor
|
77
|
-
describe "when asked for sections " do
|
78
|
-
it "must return at least 5 of them" do
|
79
|
-
@uw.sections(1999, curriculum: "OPMGT").size.must_be :>, 5
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "when asked for sections in a quarter " do
|
84
|
-
it "must return at least 5 of them" do
|
85
|
-
@uw.sections(2000, curriculum: "engl", quarter: "autumn")
|
86
|
-
.size.must_be :>, 5
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "when asked for future sections " do
|
91
|
-
it "must return at 898 of them" do
|
92
|
-
@uw.sections(2000, curriculum: "engl", quarter: "autumn", count: 3)
|
93
|
-
.size.must_equal(898)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "when asked for sections in a course " do
|
98
|
-
it "must return at least 2 of them" do
|
99
|
-
@uw.sections(1992, curriculum: "OPMGT", quarter: "winter",
|
100
|
-
course_num: 301).size.must_be :>, 2
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "when asked for sections an instructor is teaching " do
|
105
|
-
it "must return at least 1 of them" do
|
106
|
-
@uw.sections(2009, instructor: "78BE067C6A7D11D5A4AE0004AC494FFE",
|
107
|
-
quarter: terms[2]).size.must_be :>, 0
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "when asked for section with a HEPPS error " do
|
112
|
-
it "must respond with error 500" do
|
113
|
-
@uw.section(2013, "autumn", "PB AF", 521, "A").must_be_nil
|
114
|
-
end
|
115
|
-
end
|
116
|
-
# course searches
|
117
|
-
# cirric is not needed if searching by course number
|
118
|
-
# future terms must be 0-2, but, must be zero if exclude course w/o section
|
119
|
-
# make sure to page larger results using page_size and page_start
|
120
|
-
# while !@uw.next.nil?
|
121
|
-
# get result, append, next
|
122
|
-
# the following query string attributes dont seem to work
|
123
|
-
# course_title_starts, course_title_contains,
|
124
|
-
|
125
|
-
describe "when asked for courses in a curriculm " do
|
126
|
-
it "must return at least 10 of them" do
|
127
|
-
@uw.courses(1985, "winter", curriculum: "GEOG").size.must_be :>, 9
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe "when asked for courses having number = 100 " do
|
132
|
-
it "must return at least 10 of them" do
|
133
|
-
@uw.courses(1985, "winter", course: 100).size.must_be :>, 9
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "when asked for courses having number = 100 with future terms " do
|
138
|
-
it "must return at least 10 of them" do
|
139
|
-
@uw.courses(2013, "winter", course: 100, count: 2).size.must_be :>, 9
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe "when asked for courses in a curriculm having sections " do
|
144
|
-
it "must return at least 5 of them" do
|
145
|
-
@uw.courses(2005, "autumn", curriculum: "ENGL", has_sections: "on")
|
146
|
-
.size.must_be :>, 5
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "when paging courses in a curriculm " do
|
151
|
-
it "must have a url that indicates next page" do
|
152
|
-
# this particular curric has 107 courses
|
153
|
-
# ideally, you would want to join results until .next is empty
|
154
|
-
@uw.courses(1985, "autumn", curriculum: "GEOG", size: 25)
|
155
|
-
@uw.next.wont_be_empty
|
156
|
-
@uw.courses(nil, nil, get_next: true).size.must_equal(25)
|
157
|
-
@uw.courses(nil, nil, get_next: true).size.must_equal(25)
|
158
|
-
@uw.courses(nil, nil, get_next: true).size.must_equal(25)
|
159
|
-
@uw.courses(nil, nil, get_next: true).size.must_equal(7)
|
160
|
-
@uw.next.must_be_empty
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe "when asked for courses without sections " do
|
165
|
-
it "must return less than with sections" do
|
166
|
-
@uw.courses(1985, "autumn", curriculum: "GEOG", size: 150)
|
167
|
-
count_with = @uw.last["TotalCount"]
|
168
|
-
|
169
|
-
@uw.courses(1985, "autumn", curriculum: "GEOG", size: 150,
|
170
|
-
has_sections: "on")
|
171
|
-
count_without = @uw.last["TotalCount"]
|
172
|
-
|
173
|
-
count_with.must_be :>, count_without
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
#
|
178
|
-
# remaining public endpoints
|
179
|
-
#
|
180
|
-
describe "when asked for a course " do
|
181
|
-
it "must return course data" do
|
182
|
-
data = @uw.course(1992, "autumn", "CSE", 142)
|
183
|
-
data["FirstEffectiveTerm"].wont_be_empty
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
describe "when asked for a section " do
|
188
|
-
it "must have 8 enrolled" do
|
189
|
-
# who were these first 8 to take this infamous course?
|
190
|
-
# I took it in 2002...it was C++ then
|
191
|
-
data = @uw.section(1992, "autumn", "CSE", 142, "AA")
|
192
|
-
data["CurrentEnrollment"].must_equal("8")
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
describe "when asked to test a section with a zero start room number " do
|
197
|
-
it "must return without error" do
|
198
|
-
@uw.section(2010, "spring", "ARTS", 150, "A").wont_be_nil
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|