uw_sws 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +677 -0
- data/README.md +63 -0
- data/Rakefile +9 -0
- data/lib/uw_sws/version.rb +3 -0
- data/lib/uw_sws.rb +303 -0
- data/test/test_private_endpoints.rb +161 -0
- data/test/test_public_endpoints.rb +201 -0
- data/uw_sws.gemspec +25 -0
- metadata +98 -0
@@ -0,0 +1,201 @@
|
|
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
|
data/uw_sws.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uw_sws/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "uw_sws"
|
8
|
+
spec.version = UwSws::VERSION
|
9
|
+
spec.authors = ["Nogbit"]
|
10
|
+
spec.email = ["milesm@uw.edu"]
|
11
|
+
spec.description = %q{Interfaces with UW Student Web Service}
|
12
|
+
spec.summary = %q{Wraps most of the rest endpoints}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "rest-client", ">= 1.6.7"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uw_sws
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nogbit
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Interfaces with UW Student Web Service
|
56
|
+
email:
|
57
|
+
- milesm@uw.edu
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/uw_sws.rb
|
68
|
+
- lib/uw_sws/version.rb
|
69
|
+
- test/test_private_endpoints.rb
|
70
|
+
- test/test_public_endpoints.rb
|
71
|
+
- uw_sws.gemspec
|
72
|
+
homepage: ''
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Wraps most of the rest endpoints
|
96
|
+
test_files:
|
97
|
+
- test/test_private_endpoints.rb
|
98
|
+
- test/test_public_endpoints.rb
|