mitchellh-rubyuw 0.5.0 → 0.6.0
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.
- data/VERSION +1 -1
- data/lib/myuw/registration.rb +98 -0
- data/lib/myuw/schedule.rb +3 -0
- data/lib/myuw.rb +3 -0
- data/rubyuw.gemspec +14 -3
- data/test/live/registration_test.rb +46 -0
- data/test/mocked/fixture_pages/registration.html +699 -0
- data/test/mocked/fixture_pages/registration_error.html +699 -0
- data/test/mocked/fixture_pages/registration_error_no_rows.html +627 -0
- data/test/mocked/fixture_pages/registration_no_form.html +700 -0
- data/test/mocked/fixture_pages/registration_success.html +718 -0
- data/test/mocked/fixture_pages/registration_unknown.html +721 -0
- data/test/mocked/myuw_test.rb +5 -0
- data/test/mocked/registration_test.rb +105 -0
- metadata +13 -2
data/test/mocked/myuw_test.rb
CHANGED
@@ -28,5 +28,10 @@ class MyUWTest < Test::Unit::TestCase
|
|
28
28
|
assert @myuw.schedule
|
29
29
|
assert @myuw.schedule.kind_of?(MyUW::Schedule)
|
30
30
|
end
|
31
|
+
|
32
|
+
should "initialize the registration object" do
|
33
|
+
assert @myuw.registration
|
34
|
+
assert @myuw.registration.kind_of?(MyUW::Registration)
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
|
3
|
+
class MockedRegistrationTest < Test::Unit::TestCase
|
4
|
+
def get_fixture_form
|
5
|
+
fixture_page = @browser.get(path_to_html("registration"))
|
6
|
+
fixture_form = fixture_page.form_with(:name => 'regform')
|
7
|
+
assert fixture_form
|
8
|
+
assert fixture_form.kind_of?(WWW::Mechanize::Form) # Sanity
|
9
|
+
|
10
|
+
fixture_form
|
11
|
+
end
|
12
|
+
|
13
|
+
context "registering for a course" do
|
14
|
+
setup do
|
15
|
+
@myuw = MyUW.new
|
16
|
+
@myuw.stubs(:logged_in?).returns(true)
|
17
|
+
@browser = @myuw.browser
|
18
|
+
@browser.follow_meta_refresh = false
|
19
|
+
@registration = @myuw.registration
|
20
|
+
|
21
|
+
@courses = ["123456", "123321"]
|
22
|
+
end
|
23
|
+
|
24
|
+
should "raise a NotLoggedInError if user is not logged in" do
|
25
|
+
@myuw.stubs(:logged_in?).returns(false)
|
26
|
+
|
27
|
+
assert_raise MyUW::NotLoggedInError do
|
28
|
+
@registration.register("123456")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
should "raise an InvalidPageError if it does not contain the registration form" do
|
33
|
+
fixture_page = @browser.get(path_to_html("registration_no_form"))
|
34
|
+
@browser.expects(:get).returns(fixture_page)
|
35
|
+
|
36
|
+
assert_raise MyUW::InvalidPageError do
|
37
|
+
@registration.register("123456")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
should "say the start index is 4 for the fixture form" do
|
42
|
+
fixture_form = get_fixture_form
|
43
|
+
|
44
|
+
assert_equal "4", @registration.get_add_section_index(fixture_form)
|
45
|
+
end
|
46
|
+
|
47
|
+
should "start filling in the sln values at the right index" do
|
48
|
+
fixture_form = get_fixture_form
|
49
|
+
start_index = @registration.get_add_section_index(fixture_form).to_i
|
50
|
+
|
51
|
+
assert_nothing_raised { @registration.fill_registration_form(fixture_form, @courses) }
|
52
|
+
@courses.each_index do |i|
|
53
|
+
assert_equal @courses[i], fixture_form["sln#{i + start_index}"]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "analyzing registration result" do
|
59
|
+
setup do
|
60
|
+
@myuw = MyUW.new
|
61
|
+
@myuw.stubs(:logged_in?).returns(true)
|
62
|
+
@browser = @myuw.browser
|
63
|
+
@browser.follow_meta_refresh = false
|
64
|
+
@registration = @myuw.registration
|
65
|
+
end
|
66
|
+
|
67
|
+
should "return true if schedule is updated right" do
|
68
|
+
fixture_page = @browser.get(path_to_html("registration_success"))
|
69
|
+
|
70
|
+
assert @registration.get_registration_result(fixture_page)
|
71
|
+
end
|
72
|
+
|
73
|
+
should "raise InvalidPageError if something unknown occurs" do
|
74
|
+
fixture_page = @browser.get(path_to_html("registration_unknown"))
|
75
|
+
|
76
|
+
assert_raise MyUW::InvalidPageError do
|
77
|
+
@registration.get_registration_result(fixture_page)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
should "return false if schedule is not updated" do
|
82
|
+
fixture_page = @browser.get(path_to_html("registration_error"))
|
83
|
+
|
84
|
+
assert !@registration.get_registration_result(fixture_page)
|
85
|
+
assert !@registration.errors["17429"].empty?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "extracting registration errors" do
|
90
|
+
setup do
|
91
|
+
@myuw = MyUW.new
|
92
|
+
@myuw.stubs(:logged_in?).returns(true)
|
93
|
+
@browser = @myuw.browser
|
94
|
+
@browser.follow_meta_refresh = false
|
95
|
+
@registration = @myuw.registration
|
96
|
+
end
|
97
|
+
|
98
|
+
should "extract errors from an erroneous registration" do
|
99
|
+
fixture_page = @browser.get(path_to_html("registration_error"))
|
100
|
+
|
101
|
+
assert_nothing_raised { @registration.extract_registration_errors(fixture_page) }
|
102
|
+
assert_equal "To add this section, you must also register for the related 'primary' section. In most cases, the primary section is a lecture [LC] section.", @registration.errors["17429"]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mitchellh-rubyuw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitchell Hashimoto
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-28 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -37,10 +37,12 @@ files:
|
|
37
37
|
- VERSION
|
38
38
|
- lib/myuw.rb
|
39
39
|
- lib/myuw/errors.rb
|
40
|
+
- lib/myuw/registration.rb
|
40
41
|
- lib/myuw/schedule.rb
|
41
42
|
- lib/myuw/session.rb
|
42
43
|
- lib/myuw/sln.rb
|
43
44
|
- rubyuw.gemspec
|
45
|
+
- test/live/registration_test.rb
|
44
46
|
- test/live/schedule_test.rb
|
45
47
|
- test/live/session_test.rb
|
46
48
|
- test/live/sln_test.rb
|
@@ -51,6 +53,12 @@ files:
|
|
51
53
|
- test/mocked/fixture_pages/no_form_login.html
|
52
54
|
- test/mocked/fixture_pages/no_login_button.html
|
53
55
|
- test/mocked/fixture_pages/not_logged_in_relay.html
|
56
|
+
- test/mocked/fixture_pages/registration.html
|
57
|
+
- test/mocked/fixture_pages/registration_error.html
|
58
|
+
- test/mocked/fixture_pages/registration_error_no_rows.html
|
59
|
+
- test/mocked/fixture_pages/registration_no_form.html
|
60
|
+
- test/mocked/fixture_pages/registration_success.html
|
61
|
+
- test/mocked/fixture_pages/registration_unknown.html
|
54
62
|
- test/mocked/fixture_pages/schedule.html
|
55
63
|
- test/mocked/fixture_pages/schedule_diff_credit_row.html
|
56
64
|
- test/mocked/fixture_pages/schedule_empty.html
|
@@ -59,6 +67,7 @@ files:
|
|
59
67
|
- test/mocked/fixture_pages/sln_status.html
|
60
68
|
- test/mocked/fixture_pages/welcome.html
|
61
69
|
- test/mocked/myuw_test.rb
|
70
|
+
- test/mocked/registration_test.rb
|
62
71
|
- test/mocked/schedule_test.rb
|
63
72
|
- test/mocked/session_test.rb
|
64
73
|
- test/mocked/sln_test.rb
|
@@ -91,11 +100,13 @@ signing_key:
|
|
91
100
|
specification_version: 2
|
92
101
|
summary: Library which provides a ruby interface to the University of Washington student portal.
|
93
102
|
test_files:
|
103
|
+
- test/live/registration_test.rb
|
94
104
|
- test/live/schedule_test.rb
|
95
105
|
- test/live/session_test.rb
|
96
106
|
- test/live/sln_test.rb
|
97
107
|
- test/live/test_helper.rb
|
98
108
|
- test/mocked/myuw_test.rb
|
109
|
+
- test/mocked/registration_test.rb
|
99
110
|
- test/mocked/schedule_test.rb
|
100
111
|
- test/mocked/session_test.rb
|
101
112
|
- test/mocked/sln_test.rb
|