granicus-platform-api 0.1.9 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module GranicusPlatformAPI
2
- VERSION = "0.1.9"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -0,0 +1,64 @@
1
+ streaming.granicus.com:
2
+ name: Dev Daily Build
3
+ camera_id: 3
4
+ folder_id: 7
5
+ event_id: 30
6
+ event_uid: 5fa327b8-906b-102b-b291-2f582cd39e9e
7
+ import_event_id: 26
8
+ update_event_id: 35
9
+ event_meta_id: 1775
10
+ clip_id: 246
11
+ import_clip_id: 375
12
+ clip_uid: fe2a4b4b-0a69-1029-bc86-1bdd06848612
13
+ clip_meta_id: 574
14
+ clip_foreign_id: 1
15
+ event_foreign_id: 1
16
+ server_id: 2
17
+
18
+ dev.dev.granicus.com:
19
+ name: Dev Daily Build
20
+ camera_id: 1
21
+ folder_id: 1
22
+ update_event_id: 760
23
+ event_meta_id: 8883
24
+ clip_id: 719
25
+ clip_uid: 0f5e350b-7546-102e-bb2d-9326039e1073
26
+ import_clip_id: 2230
27
+ clip_meta_id: 608
28
+ clip_foreign_id: 1
29
+ event_foreign_id: 1
30
+ server_id: 1
31
+
32
+ localhost:
33
+ name: Local Build
34
+ camera_id: 1
35
+ folder_id: 1
36
+ event_id: 813
37
+ event_uid: 42a8238d-7638-102e-bb2d-9326039e1073
38
+ update_event_id: 760
39
+ event_meta_id: 8883
40
+ clip_id: 719
41
+ clip_uid: 0f5e350b-7546-102e-bb2d-9326039e1073
42
+ import_clip_id: 2230
43
+ clip_meta_id: 608
44
+ clip_foreign_id: 1
45
+ event_foreign_id: 1
46
+ server_id: 1
47
+
48
+ camera:
49
+ BroadcastPort: 8080
50
+ Type: "Meeting"
51
+ ControlPort: 80
52
+ ExternalIP: 207.7.154.140
53
+ Identifier: testcamera01
54
+ InternalIP: localhost
55
+ Name: ".gem Test Camera"
56
+
57
+ event:
58
+ Name: "platform-api-rb unit test event"
59
+ Duration: 3600
60
+ FolderID: 7
61
+ CameraID: 100
62
+ ECommentEnabled: 1
63
+ AgendaPostedDate: "2011-09-01 00:00:00"
64
+ ECommentCloseOffset: 60
@@ -1,53 +1,53 @@
1
1
  <Attendees xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="granicus:Attendee[4]">
2
- <item xsi:type="granicus:Attendee">
3
- <ID xsi:type="xsd:int">346</ID>
4
- <Name xsi:type="xsd:string">my test</Name>
5
- <Voting xsi:type="xsd:boolean">true</Voting>
6
- <Chair xsi:type="xsd:boolean">false</Chair>
7
- <OrderID xsi:type="xsd:int">1</OrderID>
8
- </item>
9
- <item xsi:type="granicus:Attendee">
10
- <ID xsi:type="xsd:int">347</ID>
11
- <Name xsi:type="xsd:string">Foo Fighters</Name>
12
- <Voting xsi:type="xsd:boolean">true</Voting>
13
- <Chair xsi:type="xsd:boolean">false</Chair>
14
- <OrderID xsi:type="xsd:int">2</OrderID>
15
- </item>
16
- <item xsi:type="granicus:Attendee">
17
- <ID xsi:type="xsd:int">348</ID>
18
- <Name xsi:type="xsd:string">another test</Name>
19
- <Voting xsi:type="xsd:boolean">true</Voting>
20
- <Chair xsi:type="xsd:boolean">false</Chair>
21
- <OrderID xsi:type="xsd:int">3</OrderID>
22
- </item>
23
- <item xsi:type="granicus:Attendee">
24
- <Name xsi:type="xsd:string">Foo Fighters</Name>
25
- <Voting xsi:type="xsd:boolean">true</Voting>
26
- <Chair xsi:type="xsd:boolean">true</Chair>
27
- </item>
28
- </Attendees>
29
-
30
-
31
- <Attendees xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ns4:Attendee[3]" SOAP-ENC:offset="[0]">
32
- <item xsi:type="ns4:Attendee">
33
- <ID xsi:type="xsd:int">349</ID>
34
- <Name xsi:type="xsd:string">my test</Name>
35
- <Voting xsi:type="xsd:boolean">true</Voting>
36
- <Chair xsi:type="xsd:boolean">false</Chair>
37
- <OrderID xsi:type="xsd:int">1</OrderID>
38
- </item>
39
- <item xsi:type="ns4:Attendee">
40
- <ID xsi:type="xsd:int">352</ID>
41
- <Name xsi:type="xsd:string">Foo Fighters</Name>
42
- <Voting xsi:type="xsd:boolean">true</Voting>
43
- <Chair xsi:type="xsd:boolean">false</Chair>
44
- <OrderID xsi:type="xsd:int">2</OrderID>
45
- </item>
46
- <item xsi:type="ns4:Attendee">
47
- <ID xsi:type="xsd:int">351</ID>
48
- <Name xsi:type="xsd:string">another test</Name>
49
- <Voting xsi:type="xsd:boolean">true</Voting>
50
- <Chair xsi:type="xsd:boolean">false</Chair>
51
- <OrderID xsi:type="xsd:int">3</OrderID>
52
- </item>
53
- </Attendees>
2
+ <item xsi:type="granicus:Attendee">
3
+ <ID xsi:type="xsd:int">346</ID>
4
+ <Name xsi:type="xsd:string">my test</Name>
5
+ <Voting xsi:type="xsd:boolean">true</Voting>
6
+ <Chair xsi:type="xsd:boolean">false</Chair>
7
+ <OrderID xsi:type="xsd:int">1</OrderID>
8
+ </item>
9
+ <item xsi:type="granicus:Attendee">
10
+ <ID xsi:type="xsd:int">347</ID>
11
+ <Name xsi:type="xsd:string">Foo Fighters</Name>
12
+ <Voting xsi:type="xsd:boolean">true</Voting>
13
+ <Chair xsi:type="xsd:boolean">false</Chair>
14
+ <OrderID xsi:type="xsd:int">2</OrderID>
15
+ </item>
16
+ <item xsi:type="granicus:Attendee">
17
+ <ID xsi:type="xsd:int">348</ID>
18
+ <Name xsi:type="xsd:string">another test</Name>
19
+ <Voting xsi:type="xsd:boolean">true</Voting>
20
+ <Chair xsi:type="xsd:boolean">false</Chair>
21
+ <OrderID xsi:type="xsd:int">3</OrderID>
22
+ </item>
23
+ <item xsi:type="granicus:Attendee">
24
+ <Name xsi:type="xsd:string">Foo Fighters</Name>
25
+ <Voting xsi:type="xsd:boolean">true</Voting>
26
+ <Chair xsi:type="xsd:boolean">true</Chair>
27
+ </item>
28
+ </Attendees>
29
+
30
+
31
+ <Attendees xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ns4:Attendee[3]" SOAP-ENC:offset="[0]">
32
+ <item xsi:type="ns4:Attendee">
33
+ <ID xsi:type="xsd:int">349</ID>
34
+ <Name xsi:type="xsd:string">my test</Name>
35
+ <Voting xsi:type="xsd:boolean">true</Voting>
36
+ <Chair xsi:type="xsd:boolean">false</Chair>
37
+ <OrderID xsi:type="xsd:int">1</OrderID>
38
+ </item>
39
+ <item xsi:type="ns4:Attendee">
40
+ <ID xsi:type="xsd:int">352</ID>
41
+ <Name xsi:type="xsd:string">Foo Fighters</Name>
42
+ <Voting xsi:type="xsd:boolean">true</Voting>
43
+ <Chair xsi:type="xsd:boolean">false</Chair>
44
+ <OrderID xsi:type="xsd:int">2</OrderID>
45
+ </item>
46
+ <item xsi:type="ns4:Attendee">
47
+ <ID xsi:type="xsd:int">351</ID>
48
+ <Name xsi:type="xsd:string">another test</Name>
49
+ <Voting xsi:type="xsd:boolean">true</Voting>
50
+ <Chair xsi:type="xsd:boolean">false</Chair>
51
+ <OrderID xsi:type="xsd:int">3</OrderID>
52
+ </item>
53
+ </Attendees>
@@ -1,234 +1,392 @@
1
- require 'helper'
2
-
3
- GRANICUS_SITE = ENV['SITE']
4
- GRANICUS_LOGIN = ENV['USERNAME']
5
- GRANICUS_PASSWORD = ENV['PASSWORD']
6
- CAMERA_ID = 3
7
- FOLDER_ID = 7
8
- EVENT_ID = 30
9
- IMPORT_EVENT_ID = 26
10
- UPDATE_EVENT_ID = 35
11
- EVENT_META_ID = 1775
12
- CLIP_ID = 246
13
- IMPORT_CLIP_ID = 375
14
- CLIP_UID = 'fe2a4b4b-0a69-1029-bc86-1bdd06848612'
15
- EVENT_UID = '5fa327b8-906b-102b-b291-2f582cd39e9e'
16
- CLIP_META_ID = 574
17
- CLIP_FOREIGN_ID = 1
18
- EVENT_FOREIGN_ID = 1
19
- SERVER_ID = 2
20
-
21
- client = GranicusPlatformAPI::Client.new GRANICUS_SITE, GRANICUS_LOGIN, GRANICUS_PASSWORD
22
-
23
- # The projects method
24
- describe GranicusPlatformAPI, "::Client.new" do
25
- it "should log me in" do
26
- logon = client.get_current_user_logon
27
- logon.should == GRANICUS_LOGIN
28
- end
29
- it "should support impersonation" do
30
- client2 = GranicusPlatformAPI::Client.new GRANICUS_SITE,nil,nil
31
- client2.impersonate client.impersonation_token
32
- client2.get_current_user_logon.should == client.get_current_user_logon
33
- end
34
- it "should support initialize without arguments" do
35
- client2 = GranicusPlatformAPI::Client.new
36
- client2.connect(GRANICUS_SITE,GRANICUS_LOGIN,GRANICUS_PASSWORD)
37
- client2.get_current_user_logon
38
- client2.logout
39
- end
40
- end
41
-
42
- describe GranicusPlatformAPI, "::Client Camera Methods" do
43
- it "should get my cameras" do
44
- cameras = client.get_cameras
45
- found = cameras.find {|c| c.ID == CAMERA_ID }
46
- found.should_not == nil
47
- end
48
- it "should create, retreive, update and delete a camera" do
49
- camera = client.get_camera CAMERA_ID
50
- new_camera_id = client.create_camera camera
51
- camera2 = client.get_camera new_camera_id
52
- camera2.Name = 'test my new camera'
53
- client.update_camera camera2
54
- camera3 = client.get_camera new_camera_id
55
- camera3.Name.should == 'test my new camera'
56
- client.delete_camera new_camera_id
57
- end
58
- end
59
-
60
- describe GranicusPlatformAPI, "::Client Event Methods" do
61
- it "should get all events" do
62
- events = client.get_events
63
- found = events.find {|e| e.ID == EVENT_ID }
64
- found.should_not == nil
65
- end
66
- it "should get the requested event" do
67
- event = client.get_event EVENT_ID
68
- event.UID = ''
69
- new_event_id = client.create_event event
70
- event2 = client.get_event new_event_id
71
- event2.Name = 'test my new event'
72
- client.update_event event2
73
- event3 = client.get_event new_event_id
74
- event3.Name.should == 'test my new event'
75
- client.delete_event new_event_id
76
- end
77
- it "should import metadata" do
78
- meta_arr = []
79
- meta1 = GranicusPlatformAPI::MetaDataData.new
80
- meta1.Name = 'test'
81
- meta1.ForeignID = 1
82
- meta2 = GranicusPlatformAPI::MetaDataData.new
83
- meta2.Name = 'test 2'
84
- meta2.ForeignID = 2
85
- meta_arr << meta1
86
- meta_arr << meta2
87
- keytable = client.import_event_meta_data IMPORT_EVENT_ID, meta_arr
88
- keytable[0].ForeignID.should == 1
89
- keytable[1].ForeignID.should == 2
90
- end
91
- it "should get all events with matching foreign id" do
92
- events = client.get_events_by_foreign_id EVENT_FOREIGN_ID
93
- events.each do |event|
94
- event.ForeignID.should == EVENT_FOREIGN_ID
95
- end
96
- end
97
- it "should update a simple property on requested event" do
98
- event = client.get_event UPDATE_EVENT_ID
99
- event.ID.should == UPDATE_EVENT_ID
100
- event.Name = 'my test'
101
- client.update_event event
102
- end
103
-
104
- it "should add a complex property on requested event" do
105
- event = client.get_event UPDATE_EVENT_ID
106
- event.ID.should == UPDATE_EVENT_ID
107
- event.Attendees << { 'Name' => "Foo Fighters", 'Voting' => true, 'Chair' => true }
108
- client.update_event event
109
- end
110
-
111
- it "should update a complex property on requested event" do
112
- event = client.get_event UPDATE_EVENT_ID
113
- event.ID.should == UPDATE_EVENT_ID
114
- event.Attendees[0].Name = 'my test'
115
- client.update_event event
116
- end
117
-
118
- it "should get the requested event by UID" do
119
- event = client.get_event_by_uid EVENT_UID
120
- event.UID.should == EVENT_UID
121
- end
122
-
123
- it "set the event agenda url" do
124
- event = client.set_event_agenda_url EVENT_ID, "http://github.com/gov20cto/granicus-platform-api"
125
- end
126
- end
127
-
128
- describe GranicusPlatformAPI, "::Client Folder Methods" do
129
- it "should get my folders" do
130
- folders = client.get_folders
131
- folders[0].ID.should == FOLDER_ID
132
- end
133
- end
134
-
135
- describe GranicusPlatformAPI, "::Client Clip Methods" do
136
- it "should get clips from the given folder" do
137
- clips = client.get_clips FOLDER_ID
138
- clips.each do |clip|
139
- clip.FolderID.should == FOLDER_ID
140
- end
141
- end
142
- it "should get all clips with matching foreign id" do
143
- clips = client.get_clips_by_foreign_id CLIP_FOREIGN_ID
144
- clips.each do |clip|
145
- clip.ForeignID.should == CLIP_FOREIGN_ID
146
- end
147
- end
148
- it "should get the requested clip" do
149
- clip = client.get_clip CLIP_ID
150
- clip.ID.should == CLIP_ID
151
- end
152
-
153
- it "should update the given clip" do
154
- clip = client.get_clip CLIP_ID
155
- name = clip.Name
156
- clip.Name = 'this is my test name'
157
- client.update_clip clip
158
- clip2 = client.get_clip CLIP_ID
159
- clip2.Name.should == 'this is my test name'
160
- clip2.Name = name
161
- client.update_clip clip2
162
- end
163
- it "should get the requested clip by UID" do
164
- clip = client.get_clip_by_uid CLIP_UID
165
- clip.UID.should == CLIP_UID
166
- end
167
- it "should import metadata" do
168
- meta_arr = []
169
- meta1 = GranicusPlatformAPI::MetaDataData.new
170
- meta1.Name = 'test'
171
- meta1.TimeStamp = 0
172
- meta1.ForeignID = 1
173
- meta2 = GranicusPlatformAPI::MetaDataData.new
174
- meta2.Name = 'test 2'
175
- meta2.TimeStamp = 30
176
- meta2.ForeignID = 2
177
- meta_arr << meta1
178
- meta_arr << meta2
179
- keytable = client.import_clip_meta_data IMPORT_CLIP_ID, meta_arr
180
- keytable[0].ForeignID.should == 1
181
- keytable[1].ForeignID.should == 2
182
- end
183
- end
184
-
185
- describe GranicusPlatformAPI, "::Client MetaData Methods" do
186
- it "should get an event's meta data" do
187
- metadata = client.get_event_meta_data EVENT_ID
188
- puts metadata
189
- found = metadata.find {|m| m.ID == EVENT_META_ID }
190
- found.should_not == nil
191
- end
192
- it "should get an event's meta data by UID" do
193
- metadata = client.get_event_meta_data_by_uid EVENT_UID
194
- found = metadata.find {|m| m.ID == EVENT_META_ID }
195
- found.should_not == nil
196
- end
197
- it "should get a clip's meta data" do
198
- metadata = client.get_clip_meta_data CLIP_ID
199
- found = metadata.find {|m| m.ID == CLIP_META_ID }
200
- found.should_not == nil
201
- end
202
-
203
- it "should get the requested meta data" do
204
- metadata = client.get_meta_data CLIP_META_ID
205
- metadata.ID = CLIP_META_ID
206
- end
207
- it "should update the metadata" do
208
- metadata = client.get_meta_data CLIP_META_ID
209
- old_name = metadata.Name
210
- metadata.Name = 'test'
211
- client.update_meta_data metadata
212
- client.get_meta_data(CLIP_META_ID).Name.should == 'test'
213
- metadata.Name = old_name
214
- client.update_meta_data metadata
215
- end
216
- end
217
-
218
- describe GranicusPlatformAPI, "::Client Server Methods" do
219
- it "should get all servers" do
220
- servers = client.get_servers
221
- found = servers.find {|s| s.ID == SERVER_ID }
222
- found.should_not == nil
223
- end
224
- it "should get the requested server" do
225
- server = client.get_server SERVER_ID
226
- server.ID.should == SERVER_D
227
- end
228
- end
229
-
230
- describe GranicusPlatformAPI, "::Client.logout" do
231
- it "should log me out" do
232
- value = client.logout
233
- end
234
- end
1
+ require 'helper'
2
+
3
+ GRANICUS_SITE = ENV['GRANICUS_SITE']
4
+ GRANICUS_LOGIN = ENV['GRANICUS_LOGIN']
5
+ GRANICUS_PASSWORD = ENV['GRANICUS_PASSWORD']
6
+
7
+ unless GRANICUS_SITE && GRANICUS_LOGIN && GRANICUS_PASSWORD
8
+ raise "The environment variables GRANICUS_SITE, GRANICUS_LOGIN, GRANICUS_PASSWORD are required to be set on the system"
9
+ end
10
+
11
+ # load fixtures based on the GRANICUS_SITE environment variable
12
+ fixtures = YAML.load(ERB.new(File.new(File.dirname(__FILE__) + '/fixtures/fixtures.yml').read).result)
13
+ site_settings = fixtures[GRANICUS_SITE]
14
+ CAMERA = fixtures["camera"]
15
+ EVENT = fixtures["event"]
16
+
17
+ CAMERA_ID = site_settings["camera_id"]
18
+ FOLDER_ID = site_settings["folder_id"]
19
+ IMPORT_EVENT_ID = site_settings["import_event_id"]
20
+ UPDATE_EVENT_ID = site_settings["update_event_id"]
21
+ EVENT_META_ID = site_settings["event_meta_id"]
22
+ CLIP_ID = site_settings["clip_id"]
23
+ IMPORT_CLIP_ID = site_settings["import_clip_id"]
24
+ CLIP_UID = site_settings["clip_uid"]
25
+ CLIP_META_ID = site_settings["clip_meta_id"]
26
+ CLIP_FOREIGN_ID = site_settings["clip_foreign_id"]
27
+ EVENT_FOREIGN_ID = site_settings["event_foreign_id"]
28
+ SERVER_ID = site_settings["server_id"]
29
+ SITE_NAME = site_settings["name"]
30
+
31
+ client = GranicusPlatformAPI::Client.new GRANICUS_SITE, GRANICUS_LOGIN, GRANICUS_PASSWORD
32
+
33
+ # The projects method
34
+ describe GranicusPlatformAPI, "::Client.new" do
35
+ it "should log me in" do
36
+ logon = client.get_current_user_logon
37
+ logon.should == GRANICUS_LOGIN
38
+ end
39
+
40
+ it "should support impersonation" do
41
+ client2 = GranicusPlatformAPI::Client.new GRANICUS_SITE, nil, nil
42
+ client2.impersonate client.impersonation_token
43
+ client2.get_current_user_logon.should == client.get_current_user_logon
44
+ end
45
+
46
+ it "should support initialize without arguments" do
47
+ client2 = GranicusPlatformAPI::Client.new
48
+ client2.connect(GRANICUS_SITE, GRANICUS_LOGIN, GRANICUS_PASSWORD)
49
+ client2.get_current_user_logon
50
+ client2.logout
51
+ end
52
+ end
53
+
54
+ describe GranicusPlatformAPI, "::Client Camera Methods" do
55
+ before do
56
+ camera = GranicusPlatformAPI::CameraData.new
57
+ camera.BroadcastPort = CAMERA["BroadcastPort"]
58
+ camera.Type = CAMERA["Type"]
59
+ camera.ControlPort = CAMERA["ControlPort"]
60
+ camera.ExternalIP = CAMERA["ExternalIP"]
61
+ camera.Identifier = CAMERA["Identifier"]
62
+ camera.InternalIP = CAMERA["InternalIP"]
63
+ camera.Name = CAMERA["Name"]
64
+ @new_camera_id = client.create_camera camera
65
+ @camera = client.get_camera(@new_camera_id)
66
+ end
67
+
68
+ it "should create a camera" do
69
+ @new_camera_id.should_not == nil
70
+ end
71
+
72
+ it "should get a camera" do
73
+ @camera.should_not == nil
74
+ end
75
+
76
+ it "should get all cameras" do
77
+ cameras = client.get_cameras
78
+ found = cameras.find { |c| c.ID == @camera.ID }
79
+ found.should_not == nil
80
+ end
81
+
82
+ it "should retrieve and update a camera" do
83
+ camera2 = client.get_camera @camera.ID
84
+ camera2.Name = 'test my new camera'
85
+ client.update_camera camera2
86
+
87
+ camera3 = client.get_camera @camera.ID
88
+ camera3.Name.should == 'test my new camera'
89
+ end
90
+
91
+ it "should delete a camera" do
92
+ client.delete_camera @camera.ID
93
+ end
94
+
95
+ after do
96
+ client.delete_camera @camera.ID
97
+ end
98
+
99
+ end
100
+
101
+ describe GranicusPlatformAPI, "::Client Event Methods" do
102
+ before do
103
+ event = GranicusPlatformAPI::EventData.new
104
+ event.Name = EVENT["Name"]
105
+ event.Duration = EVENT["Duration"]
106
+ event.FolderID = EVENT["FolderID"]
107
+ event.CameraID = EVENT["CameraID"]
108
+ event.ECommentEnabled = EVENT["ECommentEnabled"]
109
+ event.AgendaPostedDate = EVENT["AgendaPostedDate"]
110
+ event.Attendees = []
111
+ event.ECommentCloseOffset = EVENT["ECommentCloseOffset"]
112
+ event.StartTime = Time.now() - 300
113
+ event.FolderID = client.get_folders()[0].ID
114
+ event.CameraID = client.get_cameras()[0].ID
115
+ @new_event_id = client.create_event event
116
+ @event = client.get_event @new_event_id
117
+ end
118
+
119
+ it "should create an event" do
120
+ @new_event_id.should_not == nil
121
+ end
122
+
123
+ it "should get an event by ID" do
124
+ # retrieve one
125
+ @event.should_not == nil
126
+ end
127
+
128
+ it "should get an event by UID" do
129
+ # retrieve one by UID
130
+ event = client.get_event_by_uid @event.UID
131
+ event.ID.should == @event.ID
132
+ end
133
+
134
+ it "should get all events" do
135
+ # retrieve many
136
+ events = client.get_events
137
+ found = events.find { |e| e.ID == @event.ID }
138
+ found.should_not == nil
139
+ end
140
+
141
+ it "should be updatedable" do
142
+ # update
143
+ event = client.get_event @event.ID
144
+ event.Name = 'platform-api-rb unit test event updated'
145
+ client.update_event(event)
146
+
147
+ event2 = client.get_event @event.ID
148
+ event2.Name.should == 'platform-api-rb unit test event updated'
149
+ end
150
+
151
+ it "should support metadata operations" do
152
+ event = client.get_event @event.ID
153
+ event.UID = ''
154
+ new_event_id = client.create_event event
155
+ new_event = client.get_event new_event_id
156
+ meta_arr = []
157
+ meta1 = GranicusPlatformAPI::MetaDataData.new
158
+ meta1.Name = 'test'
159
+ meta1.ForeignID = 1
160
+ meta2 = GranicusPlatformAPI::MetaDataData.new
161
+ meta2.Name = 'test 2'
162
+ meta2.ForeignID = 2
163
+ meta_arr << meta1
164
+ meta_arr << meta2
165
+ keytable = client.import_event_meta_data new_event_id, meta_arr
166
+ keytable[0].ForeignID.should == 1
167
+ keytable[1].ForeignID.should == 2
168
+
169
+ # fetch out the metadata and make sure it matches
170
+ meta_tree = client.get_event_meta_data new_event_id
171
+ meta_tree[0].ID.should == keytable[0].GranicusID
172
+ meta_tree[1].ID.should == keytable[1].GranicusID
173
+
174
+ # fetch out the metadata by UID and make sure it matches
175
+ meta_tree = client.get_event_meta_data_by_uid new_event.UID
176
+ meta_tree[0].ID.should == keytable[0].GranicusID
177
+ meta_tree[1].ID.should == keytable[1].GranicusID
178
+
179
+ client.delete_event new_event_id
180
+ end
181
+
182
+ it "should have the EComment-specific fields" do
183
+ event = client.get_event @event.ID
184
+ event.NextStartDate.should_not == nil
185
+ event.ECommentEnabled.should_not == nil
186
+ end
187
+
188
+ it "should get all events with matching foreign id" do
189
+ events = client.get_events_by_foreign_id EVENT_FOREIGN_ID
190
+ events.each do |event|
191
+ event.ForeignID.should == EVENT_FOREIGN_ID
192
+ end
193
+ end
194
+
195
+ it "should update a simple property on requested event" do
196
+ event = client.get_event @event.ID
197
+ event.ID.should == @event.ID
198
+ event.Name = 'my test'
199
+ client.update_event event
200
+ end
201
+
202
+ it "should add a complex property on requested event" do
203
+ event = client.get_event @event.ID
204
+ event.ID.should == @event.ID
205
+ att1 = GranicusPlatformAPI::Attendee.new
206
+ att1.Name = 'Foo Fighters'
207
+ att1.Voting = true
208
+ att1.Chair = true
209
+ event.Attendees << att1
210
+ client.update_event event
211
+ end
212
+
213
+ it "should update a complex property on requested event" do
214
+ # create
215
+ event = client.get_event @event.ID
216
+ event.ID.should == @event.ID
217
+ att1 = GranicusPlatformAPI::Attendee.new
218
+ att1.Name = 'Foo Fighters'
219
+ att1.Voting = true
220
+ att1.Chair = true
221
+ event.Attendees << att1
222
+ client.update_event event
223
+
224
+ # update
225
+ event = client.get_event @event.ID
226
+ event.Attendees[0].Name = 'Nirvana'
227
+ client.update_event event
228
+
229
+ event = client.get_event @event.ID
230
+ event.ID.should == @event.ID
231
+ event.Attendees[0].Name.should == 'Nirvana'
232
+ end
233
+
234
+ it "set the event agenda url" do
235
+ client.set_event_agenda_url @event.ID, "http://github.com/gov20cto/granicus-platform-api"
236
+ end
237
+
238
+ it "should delete event" do
239
+ client.delete_event @event.ID
240
+ end
241
+
242
+ after do
243
+ client.delete_event @event.ID
244
+ end
245
+
246
+ end
247
+
248
+ describe GranicusPlatformAPI, "::EComment Methods" do
249
+ it "should get ecomments by event id" do
250
+ comments = client.get_ecomments_by_event_id(811)
251
+ comments.should be_kind_of(Array)
252
+ end
253
+
254
+ it "should get ecomments by agenda item uid" do
255
+ comments = client.get_ecomments_by_agenda_item_uid("42a8238d-7638-102e-bb2d-9326039e1073")
256
+ comments.should be_kind_of(Array)
257
+ end
258
+ end
259
+
260
+ describe GranicusPlatformAPI, "::Client Folder Methods" do
261
+ it "should get my folders" do
262
+ folders = client.get_folders
263
+ found = folders.find { |f| f.ID == FOLDER_ID }
264
+ found.should_not == nil
265
+ end
266
+ end
267
+
268
+ describe GranicusPlatformAPI, "::Client Clip Methods" do
269
+ it "should get clips from the given folder" do
270
+ clips = client.get_clips FOLDER_ID
271
+ clips.each do |clip|
272
+ clip.FolderID.should == FOLDER_ID
273
+ end
274
+ end
275
+
276
+ it "should get all clips with matching foreign id" do
277
+ clips = client.get_clips_by_foreign_id CLIP_FOREIGN_ID
278
+ clips.each do |clip|
279
+ clip.ForeignID.should == CLIP_FOREIGN_ID
280
+ end
281
+ end
282
+
283
+ it "should get the requested clip" do
284
+ clip = client.get_clip CLIP_ID
285
+ clip.ID.should == CLIP_ID
286
+ end
287
+
288
+ it "should update the given clip" do
289
+ clip = client.get_clip CLIP_ID
290
+ name = clip.Name
291
+ clip.Name = 'this is my test name'
292
+ client.update_clip clip
293
+ clip2 = client.get_clip CLIP_ID
294
+ clip2.Name.should == 'this is my test name'
295
+ clip2.Name = name
296
+ client.update_clip clip2
297
+ end
298
+
299
+ it "should get the requested clip by UID" do
300
+ clip = client.get_clip_by_uid CLIP_UID
301
+ clip.UID.should == CLIP_UID
302
+ end
303
+
304
+ it "should import metadata" do
305
+ meta_arr = []
306
+ meta1 = GranicusPlatformAPI::MetaDataData.new
307
+ meta1.Name = 'test'
308
+ meta1.TimeStamp = 0
309
+ meta1.ForeignID = 1
310
+ meta2 = GranicusPlatformAPI::MetaDataData.new
311
+ meta2.Name = 'test 2'
312
+ meta2.TimeStamp = 30
313
+ meta2.ForeignID = 2
314
+ meta_arr << meta1
315
+ meta_arr << meta2
316
+ keytable = client.import_clip_meta_data IMPORT_CLIP_ID, meta_arr
317
+ keytable[0].ForeignID.should == 1
318
+ keytable[1].ForeignID.should == 2
319
+ end
320
+ end
321
+
322
+ describe GranicusPlatformAPI, "::Client MetaData Methods" do
323
+
324
+ it "should get a clip's meta data" do
325
+ metadata = client.get_clip_meta_data CLIP_ID
326
+ found = metadata.find { |m| m.ID == CLIP_META_ID }
327
+ found.should_not == nil
328
+ end
329
+
330
+ it "should get the requested meta data" do
331
+ metadata = client.get_meta_data CLIP_META_ID
332
+ metadata.ID = CLIP_META_ID
333
+ end
334
+
335
+ it "should support uploading and downloading documents" do
336
+ document = GranicusPlatformAPI::Document.new
337
+ document.Description = "My test document"
338
+ document.FileContents = fixture('About Stacks.pdf')
339
+ document.FileExtension = document.FileContents.path.split('.').last
340
+ document_meta = GranicusPlatformAPI::MetaDataData.new
341
+ document_meta.Name = 'test doc'
342
+ document_meta.ForeignID = 2
343
+ document_meta.Payload = document
344
+ document_meta.ParentID = CLIP_META_ID
345
+ keymap = client.add_clip_meta_data CLIP_ID, document_meta
346
+ attachment = client.fetch_attachment keymap[0].GranicusID
347
+ attachment.FileExtension.should == document.FileExtension
348
+ attachment.FileContents.length.should == document.FileContents.size
349
+ end
350
+
351
+ it "should update the metadata" do
352
+ metadata = client.get_meta_data CLIP_META_ID
353
+ old_name = metadata.Name
354
+ metadata.Name = 'test'
355
+ client.update_meta_data metadata
356
+ client.get_meta_data(CLIP_META_ID).Name.should == 'test'
357
+ metadata.Name = old_name
358
+ client.update_meta_data metadata
359
+ end
360
+ end
361
+
362
+ describe GranicusPlatformAPI, "::Client Server Methods" do
363
+ it "should get all servers" do
364
+ servers = client.get_servers
365
+ found = servers.find { |s| s.ID == SERVER_ID }
366
+ found.should_not == nil
367
+ end
368
+
369
+ it "should get the requested server" do
370
+ server = client.get_server SERVER_ID
371
+ server.ID.should == SERVER_ID
372
+ end
373
+ end
374
+
375
+ describe GranicusPlatformAPI, "::Settings Methods" do
376
+ it "should support getting settings" do
377
+ settings = client.get_settings
378
+ found = settings.find { |s| s.Name == "name" && s.Value == SITE_NAME }
379
+ found.should_not == nil
380
+ end
381
+ it "should not return database setting" do
382
+ settings = client.get_settings
383
+ found = settings.find { |s| s.Name == "database" }
384
+ found.should == nil
385
+ end
386
+ end
387
+
388
+ describe GranicusPlatformAPI, "::Client.logout" do
389
+ it "should log me out" do
390
+ value = client.logout
391
+ end
392
+ end