powerapi 1.0.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.
@@ -0,0 +1,127 @@
1
+ require "spec_helper"
2
+
3
+ describe PowerAPI::Section do
4
+ include Savon::SpecHelper
5
+
6
+ before(:all) {
7
+ savon.mock!
8
+
9
+ @session = {:locale=>nil, :server_current_time=>"2014-08-24T03:01:25.007Z", :server_info=>{:api_version=>"2.1.1", :day_light_savings=>"0", :parent_saml_end_point=>nil, :raw_offset=>"-14400000", :server_time=>"2014-08-24T20:19:32.640Z", :student_saml_end_point=>nil, :teacher_saml_end_point=>nil, :time_zone_name=>"BOT", :"@xsi:type"=>"ax287:ServerInfo"}, :service_ticket=>"AAABSAX2Ex5NZXRA4/w06RyTFVkPGkFNEiI3qRAS5pMC7TQkWqT2UQYfVv0/c0SaE70JFJa17maweiMcP1u0skwbYAVPoyNvduejg61AdiePjqJPyhJyJGyGHi3UmuWI", :student_i_ds=>"1", :user_id=>"1", :user_type=>"2", :"@xsi:type"=>"ax284:UserSessionVO"}
10
+ }
11
+
12
+ after(:all) {
13
+ savon.unmock!
14
+ }
15
+
16
+ before(:each) {
17
+ fixture = File.read("spec/fixtures/transcript.json")
18
+ message = {
19
+ userSessionVO: {
20
+ userId: "1",
21
+ serviceTicket: "AAABSAX2Ex5NZXRA4/w06RyTFVkPGkFNEiI3qRAS5pMC7TQkWqT2UQYfVv0/c0SaE70JFJa17maweiMcP1u0skwbYAVPoyNvduejg61AdiePjqJPyhJyJGyGHi3UmuWI",
22
+ serverInfo: {
23
+ apiVersion: "2.1.1"
24
+ },
25
+ serverCurrentTime: "2012-12-26T21:47:23.792Z",
26
+ userType: "2"
27
+ },
28
+ studentIDs: "1",
29
+ qil: {
30
+ includes: "1"
31
+ }
32
+ }
33
+
34
+ savon.expects(:get_student_data).with(message: message).returns(fixture)
35
+
36
+ student = PowerAPI::Student.new("http://powerschool.example", @session)
37
+
38
+ @section0 = student.sections[0]
39
+ @section1 = student.sections[1]
40
+ }
41
+
42
+ after(:each) {
43
+ @section0 = nil
44
+ }
45
+
46
+ describe "#assignments" do
47
+ it "has one assignment" do
48
+ expect(
49
+ @section0.assignments.count
50
+ ).to be(1)
51
+ end
52
+
53
+ it "has a PowerAPI::Assignment instance at index 0" do
54
+ expect(
55
+ @section0.assignments[0]
56
+ ).to be_an_instance_of(PowerAPI::Assignment)
57
+ end
58
+ end
59
+
60
+ describe "#final_grades" do
61
+ it "has one final grade at index 0" do
62
+ expect(
63
+ @section0.final_grades.length
64
+ ).to be(1)
65
+ end
66
+
67
+ it "returns nil for final grades at index 1" do
68
+ expect(
69
+ @section1.final_grades
70
+ ).to be_nil
71
+ end
72
+
73
+ it "has a Q1 key at index 0" do
74
+ expect(
75
+ @section0.final_grades
76
+ ).to include("Q1")
77
+ end
78
+
79
+ it "has a Q1 score of 100% at index 0" do
80
+ expect(
81
+ @section0.final_grades["Q1"]
82
+ ).to be(100)
83
+ end
84
+ end
85
+
86
+ describe "#name" do
87
+ it "is called Sample Section at index 0" do
88
+ expect(
89
+ @section0.name
90
+ ).to eq("Sample Section")
91
+ end
92
+ end
93
+
94
+ describe "#room_name" do
95
+ it "is in room HS101 at index 0" do
96
+ expect(
97
+ @section0.room_name
98
+ ).to eq("HS101")
99
+ end
100
+ end
101
+
102
+ describe "#teacher" do
103
+ it "has the first name Mary at index 0" do
104
+ expect(
105
+ @section0.teacher[:first_name]
106
+ ).to eq("Mary")
107
+ end
108
+
109
+ it "has the last name Mary at index 0" do
110
+ expect(
111
+ @section0.teacher[:last_name]
112
+ ).to eq("Sue")
113
+ end
114
+
115
+ it "has the email msue@example.edu at index 0" do
116
+ expect(
117
+ @section0.teacher[:email]
118
+ ).to eq("msue@example.edu")
119
+ end
120
+
121
+ it "has the school phone +00000000000 at index 0" do
122
+ expect(
123
+ @section0.teacher[:school_phone]
124
+ ).to eq("+00000000000")
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,15 @@
1
+ require "simplecov"
2
+
3
+ # Only use Coveralls when being run in CI
4
+ if ENV["CI"]
5
+ require "coveralls"
6
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
7
+ end
8
+
9
+ SimpleCov.start do
10
+ add_filter "spec"
11
+ end
12
+
13
+ require "powerapi"
14
+
15
+ require "savon/mock/spec_helper"
@@ -0,0 +1,113 @@
1
+ require "spec_helper"
2
+
3
+ describe PowerAPI::Student do
4
+ include Savon::SpecHelper
5
+
6
+ before(:all) {
7
+ savon.mock!
8
+
9
+ @session = {:locale=>nil, :server_current_time=>"2014-08-24T03:01:25.007Z", :server_info=>{:api_version=>"2.1.1", :day_light_savings=>"0", :parent_saml_end_point=>nil, :raw_offset=>"-14400000", :server_time=>"2014-08-24T20:19:32.640Z", :student_saml_end_point=>nil, :teacher_saml_end_point=>nil, :time_zone_name=>"BOT", :"@xsi:type"=>"ax287:ServerInfo"}, :service_ticket=>"AAABSAX2Ex5NZXRA4/w06RyTFVkPGkFNEiI3qRAS5pMC7TQkWqT2UQYfVv0/c0SaE70JFJa17maweiMcP1u0skwbYAVPoyNvduejg61AdiePjqJPyhJyJGyGHi3UmuWI", :student_i_ds=>"1", :user_id=>"1", :user_type=>"2", :"@xsi:type"=>"ax284:UserSessionVO"}
10
+ }
11
+
12
+ after(:all) {
13
+ savon.unmock!
14
+ }
15
+
16
+ describe "#initialize" do
17
+ before(:each) {
18
+ @student = PowerAPI::Student.new("http://powerschool.example", @session, false)
19
+ }
20
+
21
+ after(:each) {
22
+ @student = nil
23
+ }
24
+
25
+ it "returns nil for sections" do
26
+ expect(
27
+ @student.sections
28
+ ).to be_nil
29
+ end
30
+
31
+ it "returns nil for information" do
32
+ expect(
33
+ @student.information
34
+ ).to be_nil
35
+ end
36
+ end
37
+
38
+ describe "#fetch_transcript" do
39
+ it "returns something that looks like a transcript" do
40
+ fixture = File.read("spec/fixtures/transcript.json")
41
+ message = {
42
+ userSessionVO: {
43
+ userId: "1",
44
+ serviceTicket: "AAABSAX2Ex5NZXRA4/w06RyTFVkPGkFNEiI3qRAS5pMC7TQkWqT2UQYfVv0/c0SaE70JFJa17maweiMcP1u0skwbYAVPoyNvduejg61AdiePjqJPyhJyJGyGHi3UmuWI",
45
+ serverInfo: {
46
+ apiVersion: "2.1.1"
47
+ },
48
+ serverCurrentTime: "2012-12-26T21:47:23.792Z",
49
+ userType: "2"
50
+ },
51
+ studentIDs: "1",
52
+ qil: {
53
+ includes: "1"
54
+ }
55
+ }
56
+
57
+ savon.expects(:get_student_data).with(message: message).returns(fixture)
58
+
59
+ student = PowerAPI::Student.new("http://powerschool.example", @session, false)
60
+
61
+ transcript = student.fetch_transcript["return"]["studentDataVOs"]
62
+
63
+ expect(transcript).to include(
64
+ "assignmentCategories", "assignments", "assignmentScores",
65
+ "finalGrades", "reportingTerms", "schools",
66
+ "sections", "student", "teachers"
67
+ )
68
+ end
69
+ end
70
+
71
+ describe "#parse_transcript" do
72
+ before(:each) {
73
+ fixture = File.read("spec/fixtures/transcript.json")
74
+ fixture = JSON.parse(fixture)
75
+
76
+ @student = PowerAPI::Student.new("http://powerschool.example", @session, false)
77
+
78
+ @student.parse_transcript(fixture)
79
+ }
80
+
81
+ after(:each) {
82
+ @student = nil
83
+ }
84
+
85
+ it "has two sections" do
86
+ expect(
87
+ @student.sections.length
88
+ ).to be(2)
89
+ end
90
+
91
+ it "returns the student's information" do
92
+ information = {
93
+ "currentGPA"=>"4.0",
94
+ "currentMealBalance"=>0,
95
+ "currentTerm"=>"S1",
96
+ "dcid"=>1,
97
+ "dob"=>"1970-01-01T00:00:00.000Z",
98
+ "ethnicity"=>"US",
99
+ "firstName"=>"John",
100
+ "gender"=>"M",
101
+ "gradeLevel"=>12,
102
+ "id"=>1,
103
+ "lastName"=>"Doe",
104
+ "middleName"=>{"@nil"=>"true"},
105
+ "photoDate"=>{"@nil"=>"true"},
106
+ "startingMealBalance"=>0
107
+ }
108
+ expect(
109
+ @student.information
110
+ ).to eq(information)
111
+ end
112
+ end
113
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: powerapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Henri Watson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: savon
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httpclient
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.4.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.4.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: json
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 1.8.1
125
+ description: Library for fetching information from Pearson PowerSchool installs.
126
+ email:
127
+ - henri@henriwatson.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - .travis.yml
134
+ - ACKNOWLEDGEMENTS.md
135
+ - Gemfile
136
+ - README.md
137
+ - Rakefile
138
+ - lib/powerapi.rb
139
+ - lib/powerapi/assignment.rb
140
+ - lib/powerapi/exception.rb
141
+ - lib/powerapi/parser.rb
142
+ - lib/powerapi/section.rb
143
+ - lib/powerapi/student.rb
144
+ - lib/powerapi/version.rb
145
+ - powerapi.gemspec
146
+ - spec/assignment_spec.rb
147
+ - spec/fixtures/authentication/failure.xml
148
+ - spec/fixtures/authentication/success.xml
149
+ - spec/fixtures/transcript.json
150
+ - spec/parser_spec.rb
151
+ - spec/powerapi_spec.rb
152
+ - spec/section_spec.rb
153
+ - spec/spec_helper.rb
154
+ - spec/student_spec.rb
155
+ homepage: http://powerapi.henriwatson.com/
156
+ licenses:
157
+ - MIT
158
+ metadata: {}
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - '>='
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ requirements: []
174
+ rubyforge_project:
175
+ rubygems_version: 2.0.14
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Ruby API for PowerSchool.
179
+ test_files:
180
+ - spec/assignment_spec.rb
181
+ - spec/fixtures/authentication/failure.xml
182
+ - spec/fixtures/authentication/success.xml
183
+ - spec/fixtures/transcript.json
184
+ - spec/parser_spec.rb
185
+ - spec/powerapi_spec.rb
186
+ - spec/section_spec.rb
187
+ - spec/spec_helper.rb
188
+ - spec/student_spec.rb