yammer-client 0.1.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/.gitignore +29 -0
- data/.travis.yml +9 -0
- data/.yardopts +10 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +13 -0
- data/LICENSE.md +20 -0
- data/README.md +265 -0
- data/Rakefile +12 -0
- data/certs/tiabas-public.pem +21 -0
- data/lib/yammer.rb +28 -0
- data/lib/yammer/api.rb +10 -0
- data/lib/yammer/api/autocomplete.rb +25 -0
- data/lib/yammer/api/group.rb +78 -0
- data/lib/yammer/api/group_membership.rb +32 -0
- data/lib/yammer/api/message.rb +196 -0
- data/lib/yammer/api/network.rb +21 -0
- data/lib/yammer/api/notification.rb +18 -0
- data/lib/yammer/api/search.rb +28 -0
- data/lib/yammer/api/thread.rb +23 -0
- data/lib/yammer/api/topic.rb +21 -0
- data/lib/yammer/api/user.rb +156 -0
- data/lib/yammer/client.rb +101 -0
- data/lib/yammer/configurable.rb +46 -0
- data/lib/yammer/error.rb +61 -0
- data/lib/yammer/http_connection.rb +184 -0
- data/lib/yammer/identity_map.rb +42 -0
- data/lib/yammer/model.rb +6 -0
- data/lib/yammer/model/base.rb +133 -0
- data/lib/yammer/model/group.rb +13 -0
- data/lib/yammer/model/group_membership.rb +11 -0
- data/lib/yammer/model/message.rb +17 -0
- data/lib/yammer/model/message_body.rb +13 -0
- data/lib/yammer/model/thread.rb +44 -0
- data/lib/yammer/model/user.rb +46 -0
- data/lib/yammer/response.rb +43 -0
- data/lib/yammer/version.rb +18 -0
- data/spec/api/autocomplete_spec.rb +23 -0
- data/spec/api/group_membership_spec.rb +30 -0
- data/spec/api/group_spec.rb +58 -0
- data/spec/api/message_spec.rb +118 -0
- data/spec/api/network_spec.rb +23 -0
- data/spec/api/notification_spec.rb +23 -0
- data/spec/api/search_spec.rb +23 -0
- data/spec/api/thread_spec.rb +23 -0
- data/spec/api/topic_spec.rb +23 -0
- data/spec/api/user_spec.rb +76 -0
- data/spec/client_spec.rb +208 -0
- data/spec/connection_spec.rb +280 -0
- data/spec/error_spec.rb +69 -0
- data/spec/fixtures/group.json +1 -0
- data/spec/fixtures/message.json +1 -0
- data/spec/fixtures/messages_in_thread.json +1 -0
- data/spec/fixtures/portal_thread.json +1 -0
- data/spec/fixtures/private_thread.json +1 -0
- data/spec/fixtures/public_thread.json +1 -0
- data/spec/fixtures/user.json +1 -0
- data/spec/identity_map_spec.rb +108 -0
- data/spec/model/base_spec.rb +155 -0
- data/spec/model/group_membership_spec.rb +27 -0
- data/spec/model/group_spec.rb +44 -0
- data/spec/model/message_spec.rb +45 -0
- data/spec/model/thread_spec.rb +66 -0
- data/spec/model/user_spec.rb +150 -0
- data/spec/response_spec.rb +66 -0
- data/spec/spec_helper.rb +42 -0
- data/yammer.gemspec +29 -0
- metadata +270 -0
@@ -0,0 +1,280 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require 'yammer/http_connection'
|
3
|
+
|
4
|
+
describe Yammer::HttpConnection do
|
5
|
+
|
6
|
+
before :all do
|
7
|
+
Yammer.configure do |conf|
|
8
|
+
conf.access_token = 'TolNOFka9Uls2DxahNi78A'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
subject do
|
13
|
+
@conn = Yammer::HttpConnection.new('https://yammer.com')
|
14
|
+
end
|
15
|
+
|
16
|
+
context "with user options" do
|
17
|
+
before do
|
18
|
+
@options = {
|
19
|
+
:headers => {
|
20
|
+
'Accept' => 'application/json',
|
21
|
+
'User-Agent' => "Yammer Ruby Gem #{Yammer::Version}"
|
22
|
+
},
|
23
|
+
:ssl => {:verify => false},
|
24
|
+
:max_redirects => 2
|
25
|
+
}
|
26
|
+
@conn = Yammer::HttpConnection.new('https://microsoft.com', @options)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "overrides default options" do
|
30
|
+
opts = Yammer::HttpConnection.default_options
|
31
|
+
opts.keys.each do |key|
|
32
|
+
expect(@conn.instance_variable_get(:"@#{key}")).to eq @options[key]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#default_headers" do
|
38
|
+
it "returns user_agent and response format" do
|
39
|
+
expect(subject.default_headers).to eq ({
|
40
|
+
"Accept" => "application/json",
|
41
|
+
"User-Agent" => "Yammer Ruby Gem #{Yammer::Version}"
|
42
|
+
})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#scheme" do
|
47
|
+
it "returns the http scheme" do
|
48
|
+
expect(subject.scheme).to eq 'https'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#scheme" do
|
53
|
+
context "scheme is unsupported" do
|
54
|
+
it "raises an error" do
|
55
|
+
expect { subject.scheme = 'ftp'}.to raise_error(Yammer::HttpConnection::UnsupportedSchemeError)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "scheme is http" do
|
60
|
+
it "sets the scheme" do
|
61
|
+
subject.scheme = 'http'
|
62
|
+
expect(subject.scheme).to eq 'http'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "scheme is https" do
|
67
|
+
it "sets the scheme" do
|
68
|
+
subject.scheme = 'https'
|
69
|
+
expect(subject.scheme).to eq 'https'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#host" do
|
75
|
+
it "returns the host server" do
|
76
|
+
expect(subject.host).to eq 'yammer.com'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#port" do
|
81
|
+
it "returns the port" do
|
82
|
+
expect(subject.port).to eq 443
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#ssl?" do
|
87
|
+
context "scheme is https" do
|
88
|
+
it "returns true" do
|
89
|
+
subject.scheme = 'https'
|
90
|
+
expect(subject.ssl?).to eq true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "scheme is http" do
|
95
|
+
it "returns false" do
|
96
|
+
subject.scheme = 'http'
|
97
|
+
expect(subject.ssl?).to eq false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#http_connection" do
|
103
|
+
it "behaves like HTTP client" do
|
104
|
+
expect(subject.http_connection).to respond_to(:get)
|
105
|
+
expect(subject.http_connection).to respond_to(:post)
|
106
|
+
expect(subject.http_connection).to respond_to(:put)
|
107
|
+
expect(subject.http_connection).to respond_to(:delete)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "#absolute_url" do
|
112
|
+
context "with no parameters" do
|
113
|
+
it "returns a uri without path" do
|
114
|
+
expect(subject.absolute_url).to eq "https://yammer.com"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "with parameters" do
|
119
|
+
it "returns a uri with path" do
|
120
|
+
expect(subject.absolute_url('/oauth/v2/authorize')).to eq "https://yammer.com/oauth/v2/authorize"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#configure_ssl" do
|
126
|
+
end
|
127
|
+
|
128
|
+
describe "#redirect_limit_reached?" do
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "#ssl_verify_mode" do
|
132
|
+
context "ssl verify set to true" do
|
133
|
+
it "returns OpenSSL::SSL::VERIFY_PEER" do
|
134
|
+
subject.ssl = { :verify => true }
|
135
|
+
expect(subject.send(:ssl_verify_mode)).to eq OpenSSL::SSL::VERIFY_PEER
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "ssl verify set to false" do
|
140
|
+
it "returns OpenSSL::SSL::VERIFY_NONE" do
|
141
|
+
subject.ssl = { :verify => false }
|
142
|
+
expect(subject.send(:ssl_verify_mode)).to eq OpenSSL::SSL::VERIFY_NONE
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe "ssl_cert_store" do
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "#send_request" do
|
151
|
+
before do
|
152
|
+
@http_ok = OpenStruct.new(
|
153
|
+
:code => '200',
|
154
|
+
:body => 'success',
|
155
|
+
:header => {'Content-Type' => "application/json"}
|
156
|
+
)
|
157
|
+
@http_redirect = OpenStruct.new(
|
158
|
+
:code => '301',
|
159
|
+
:body => 'redirect',
|
160
|
+
:header => {'Location' => "http://yammer.com/members"}
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
context "when method is not supported" do
|
165
|
+
it "raises an error" do
|
166
|
+
expect {subject.send_request(:patch, '/')}.to raise_error(Yammer::HttpConnection::UnhandledHTTPMethodError)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context "when method is get" do
|
171
|
+
it "returns an http response" do
|
172
|
+
path = '/oauth/authorize'
|
173
|
+
params = {:client_id => '001337', :client_secret => 'abcxyz'}
|
174
|
+
method = :get
|
175
|
+
|
176
|
+
normalized_path = '/oauth/authorize?client_id=001337&client_secret=abcxyz'
|
177
|
+
|
178
|
+
Net::HTTP.any_instance.should_receive(:get).with(normalized_path, subject.default_headers).and_return(@http_ok)
|
179
|
+
response = subject.send_request(method, path, :params => params)
|
180
|
+
|
181
|
+
expect(response.code).to eq '200'
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context "when method is delete" do
|
186
|
+
it "returns an http response" do
|
187
|
+
path = '/users/1'
|
188
|
+
method = 'delete'
|
189
|
+
|
190
|
+
Net::HTTP.any_instance.should_receive(:delete).with(path, subject.default_headers).and_return(@http_ok)
|
191
|
+
response = subject.send_request(method, path)
|
192
|
+
|
193
|
+
expect(response.code).to eq '200'
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "when method is post" do
|
198
|
+
it "returns an http response" do
|
199
|
+
path = '/users'
|
200
|
+
params = {:first_name => 'john', :last_name => 'smith'}
|
201
|
+
query = Addressable::URI.form_encode(params)
|
202
|
+
headers = {'Content-Type' => 'application/x-www-form-urlencoded' }.merge(subject.default_headers)
|
203
|
+
|
204
|
+
Net::HTTP.any_instance.should_receive(:post).with(path, query, headers).and_return(@http_ok)
|
205
|
+
response =subject.send_request(:post, path, :params => params)
|
206
|
+
|
207
|
+
expect(response.code).to eq '200'
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "when method is put" do
|
212
|
+
it "returns an http response" do
|
213
|
+
path = '/users/1'
|
214
|
+
params = {:first_name => 'jane', :last_name => 'doe'}
|
215
|
+
query = Addressable::URI.form_encode(params)
|
216
|
+
headers = {'Content-Type' => 'application/x-www-form-urlencoded' }.merge(subject.default_headers)
|
217
|
+
|
218
|
+
Net::HTTP.any_instance.should_receive(:put).with(path, query, headers).and_return(@http_ok)
|
219
|
+
|
220
|
+
response = subject.send_request(:put, path, :params => params)
|
221
|
+
|
222
|
+
expect(response.code).to eq '200'
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
it "follows redirect" do
|
227
|
+
path = '/users'
|
228
|
+
params = {:first_name => 'jane', :last_name => 'doe'}
|
229
|
+
query = Addressable::URI.form_encode(params)
|
230
|
+
headers = {'Content-Type' => 'application/x-www-form-urlencoded' }.merge(subject.default_headers)
|
231
|
+
client = double("client")
|
232
|
+
|
233
|
+
subject.should_receive(:http_connection).twice.and_return(client, client)
|
234
|
+
client.should_receive(:post).ordered.with(path, query, headers).and_return(@http_redirect)
|
235
|
+
client.should_receive(:post).ordered.with('/members', query, headers).and_return(@http_ok)
|
236
|
+
|
237
|
+
response = subject.send_request(:post, path, :params => params)
|
238
|
+
|
239
|
+
expect(response.code).to eq '200'
|
240
|
+
end
|
241
|
+
|
242
|
+
it "respects the redirect limit " do
|
243
|
+
subject.max_redirects = 1
|
244
|
+
path = '/users'
|
245
|
+
params = {:first_name => 'jane', :last_name => 'doe'}
|
246
|
+
query = Addressable::URI.form_encode(params)
|
247
|
+
headers = {'Content-Type' => 'application/x-www-form-urlencoded' }.merge(subject.default_headers)
|
248
|
+
client = double("client")
|
249
|
+
|
250
|
+
subject.should_receive(:http_connection).twice.and_return(client, client)
|
251
|
+
client.should_receive(:post).ordered.with(path, query, headers).and_return(@http_redirect)
|
252
|
+
client.should_receive(:post).ordered.with('/members', query, headers).and_return(@http_redirect)
|
253
|
+
|
254
|
+
response = subject.send_request(:post, path, :params => params)
|
255
|
+
|
256
|
+
expect(response.code).to eq '301'
|
257
|
+
end
|
258
|
+
|
259
|
+
it "modifies http 303 redirect from POST to GET " do
|
260
|
+
http_303 = OpenStruct.new(
|
261
|
+
:code => '303',
|
262
|
+
:body => 'redirect',
|
263
|
+
:header => {'Location' => "http://yammer.com/members"}
|
264
|
+
)
|
265
|
+
path = '/users'
|
266
|
+
params = {:first_name => 'jane', :last_name => 'doe'}
|
267
|
+
query = Addressable::URI.form_encode(params)
|
268
|
+
headers = {'Content-Type' => 'application/x-www-form-urlencoded' }.merge(subject.default_headers)
|
269
|
+
client = double("client")
|
270
|
+
|
271
|
+
subject.should_receive(:http_connection).twice.and_return(client, client)
|
272
|
+
client.should_receive(:post).ordered.with(path, query, headers).and_return(http_303)
|
273
|
+
client.should_receive(:get).ordered.with('/members', subject.default_headers).and_return(@http_ok)
|
274
|
+
|
275
|
+
response = subject.send_request(:post, path, :params => params)
|
276
|
+
|
277
|
+
expect(response.code).to eq '200'
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
data/spec/error_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe Yammer::Error do
|
4
|
+
|
5
|
+
subject { Yammer::Error }
|
6
|
+
|
7
|
+
describe 'from status' do
|
8
|
+
|
9
|
+
context 'status unknown' do
|
10
|
+
it 'returns ApiError' do
|
11
|
+
expect(subject.from_status).to eq Yammer::Error::ApiError
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'status 400' do
|
16
|
+
it 'returns BadRequest' do
|
17
|
+
expect(subject.from_status(400)).to eq Yammer::Error::BadRequest
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'status 401' do
|
22
|
+
it 'returns Unauthorized' do
|
23
|
+
expect(subject.from_status(401)).to eq Yammer::Error::Unauthorized
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'status 403' do
|
28
|
+
it 'returns Forbidden' do
|
29
|
+
expect(subject.from_status(403)).to eq Yammer::Error::Forbidden
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'status 404' do
|
34
|
+
it 'returns NotFound' do
|
35
|
+
expect(subject.from_status(404)).to eq Yammer::Error::NotFound
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'status 406' do
|
40
|
+
it 'returns NotAcceptable' do
|
41
|
+
expect(subject.from_status(406)).to eq Yammer::Error::NotAcceptable
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'status 429' do
|
46
|
+
it 'returns RateLimitExceeded' do
|
47
|
+
expect(subject.from_status(429)).to eq Yammer::Error::RateLimitExceeded
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'status 500' do
|
52
|
+
it 'returns InternalServerError' do
|
53
|
+
expect(subject.from_status(500)).to eq Yammer::Error::InternalServerError
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'status 502' do
|
58
|
+
it 'returns BadGateway' do
|
59
|
+
expect(subject.from_status(502)).to eq Yammer::Error::BadGateway
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'status 503' do
|
64
|
+
it 'returns ServiceUnavailable' do
|
65
|
+
expect(subject.from_status(503)).to eq Yammer::Error::ServiceUnavailable
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"show_in_directory":"true","privacy":"public","description":"WE KNOW PURPLE","id":2528,"creator_type":"user","creator_id":98981,"mugshot_id":"Z9SwsZvd3zr-Gm5G23wjvXDpcS0VGhJv","stats":{"last_message_at":"2013/01/05 20:43:43 +0000","members":55,"updates":7088,"last_message_id":10825877},"state":"active","web_url":"https://www.yammer.com/yammer-inc.com/groups/railsteam","name":"railsteam","created_at":"2012/02/02 23:17:35 +0000","type":"group","mugshot_url":"https://mug0.staging.assets-yammer.com/mugshot/images/48x48/Z9SwsZvd3zr-Gm5G23wjvXDpcS0VGhJv","url":"https://www.yammer.com/api/v1/groups/2528","mugshot_url_template":"https://mug0.staging.assets-yammer.com/mugshot/images/{width}x{height}/Z9SwsZvd3zr-Gm5G23wjvXDpcS0VGhJv","full_name":"RAILS TEAM"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":5,"thread_id":5,"replied_to_id":null,"sender_type":"user","attachments":[],"chat_client_sequence":null,"group_id":7,"web_url":"https://www.yammer.com/yammer-inc.com/messages/5","content_excerpt":"I don't always drink beer. But when I do, I drink Dos Equis","sender_id":67,"client_url":"https://www.yammer.com/","message_type":"update","created_at":"2012/12/08 01:23:16 +0000","network_id":8,"url":"https://www.yammer.com/api/v1/messages/5","system_message":false,"direct_message":false,"privacy":"public","body":{"plain":"I don't always drink beer. But when I do, I drink Dos Equis.","rich":"I don't always drink beer. But when I do, I drink Dos Equi.","parsed":"I don't always drink beer. But when I do, I drink Dos Equis."},"liked_by":{"count":0,"names":[]},"client_type":"Web"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"meta":{"followed_references":[],"feed_name":"Conversation","realtime":{"channel_id":"MTM6MTU0ODg6MTA5Mjg1MDg","authentication_token":"RyPh56vMMc01+XufSYwkN3ITxNbHyxfVRM4oDgUfaEh4nKtWKi1OLVKyMrQwMbQ0NtZRykstKc8vygaKmJpYWOgopVYUZBZVArnGZqYWloYGpga1AJI2DrI=","uri":"https://2.rt.yammer.com/cometd/"},"requested_poll_interval":60,"direct_from_body":false,"feed_desc":"Messages in this conversation","ymodules":[],"current_user_id":1841933,"followed_user_ids":[1908103]},"threaded_extended":{},"messages":[{"client_url":"https://www.yammer.com/","sender_type":"user","client_type":"Web","direct_message":true,"content_excerpt":"Here are some queries that pulls the thread_id (of threads from the last few months) and lets us know information about them, like is on the thread, who likes the thread, topics, what group the thread is in, how many times the thread has been shared, if there are attachements, etc....\n\nhttp://analytics.int.yammer.com/queries/2245/executions/74563\nhttp://analytics.int.yammer.com/queries/2252/executions/74592\nhttp://analytics.int.yammer.com/queries/2251/executions/74582\n\nWe need to put these tables into python for the start of the analysis.","attachments":[{"description":null,"id":3489814542165986,"object_type":"page","inline_url":"blank.html","web_url":"http://analytics.int.yammer.com/queries/2245/executions/74563","name":"http://analytics.int.yammer.com/queries/2245/executions/74563","ymodule":{"web_app_id":"open_graph_object","icon_url":"blank.gif","app_id":"blank"},"type":"ymodule","object_name":"Yammer","inline_html":"\u003Cdiv class=\"yj-open-graph-object ymodule-instance\" data-ymodule-instance=\"3489814542165986\"\u003E\n \u003Cdiv class=\"ymodule-instance-3489814542165986-container-1 yj-open-graph-no-image yj-open-graph-contents\"\u003E\n \u003Ch5 class=\"yj-title\"\u003E\n \u003Cspan\u003E\u003Ca href=\"http://analytics.int.yammer.com/queries/2245/executions/74563\" target=\"_blank\" rel=\"nofollow\"\n \u003E\n http://analytics.int.yammer.com/queries/2245/executions/74563\n \u003C/a\u003E\u003C/span\u003E\n \u003C/h5\u003E\n \u003Ch6 class=\"yj-subtitle\"\u003E\n \u003Cspan\u003Eanalytics.int.yammer.com\u003C/span\u003E\n \u003C/h6\u003E\n \u003C/div\u003E\n \u003Cdiv class=\"yj-actions-container\"\u003E\u003C/div\u003E\n\u003C/div\u003E\n","host_url":null,"thumbnail_url":null,"record_id":348981453123585}],"body":{"urls":["http://analytics.int.yammer.com/queries/2245/executions/74563","http://analytics.int.yammer.com/queries/2252/executions/74592","http://analytics.int.yammer.com/queries/2251/executions/74582"],"parsed":"Here are some queries that pulls the thread_id (of threads from the last few months) and lets us know information about them, like is on the thread, who likes the thread, topics, what group the thread is in, how many times the thread has been shared, if there are attachements, etc....\n\nhttp://analytics.int.yammer.com/queries/2245/executions/74563\nhttp://analytics.int.yammer.com/queries/2252/executions/74592\nhttp://analytics.int.yammer.com/queries/2251/executions/74582\n\nWe need to put these tables into python for the start of the analysis.","plain":"Here are some queries that pulls the thread_id (of threads from the last few months) and lets us know information about them, like is on the thread, who likes the thread, topics, what group the thread is in, how many times the thread has been shared, if there are attachements, etc....\n\nhttp://analytics.int.yammer.com/queries/2245/executions/74563\nhttp://analytics.int.yammer.com/queries/2252/executions/74592\nhttp://analytics.int.yammer.com/queries/2251/executions/74582\n\nWe need to put these tables into python for the start of the analysis.","rich":"Here are some queries that pulls the thread_id (of threads from the last few months) and lets us know information about them, like is on the thread, who likes the thread, topics, what group the thread is in, how many times the thread has been shared, if there are attachements, etc....\u003Cbr\u003E\u003Cbr\u003E\u003Ca href=\"http://analytics.int.yammer.com/queries/2245/executions/74563\" title=\"http://analytics.int.yammer.com/queries/2245/executions/74563\" target=\"_blank\" rel=\"nofollow\"\u003Ehttp://analytics.int.yammer.com/queries/2245/executions/7456\u2026\u003C/a\u003E\u003Cbr\u003E\u003Ca href=\"http://analytics.int.yammer.com/queries/2252/executions/74592\" title=\"http://analytics.int.yammer.com/queries/2252/executions/74592\" target=\"_blank\" rel=\"nofollow\"\u003Ehttp://analytics.int.yammer.com/queries/2252/executions/7459\u2026\u003C/a\u003E\u003Cbr\u003E\u003Ca href=\"http://analytics.int.yammer.com/queries/2251/executions/74582\" title=\"http://analytics.int.yammer.com/queries/2251/executions/74582\" target=\"_blank\" rel=\"nofollow\"\u003Ehttp://analytics.int.yammer.com/queries/2251/executions/7458\u2026\u003C/a\u003E\u003Cbr\u003E\u003Cbr\u003EWe need to put these tables into python for the start of the analysis."},"id":10930136,"conversation_id":324414,"system_message":false,"privacy":"private","chat_client_sequence":null,"network_id":15488,"liked_by":{"names":[],"count":0},"web_url":"https://www.yammer.com/yammer-inc.com/messages/10930136","sender_id":1908103,"created_at":"2013/03/13 21:08:48 +0000","replied_to_id":10930053,"message_type":"update","thread_id":10928508,"url":"https://www.yammer.com/api/v1/messages/10930136"}]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"topics":[],"attachments":[],"direct_message":true,"privacy":"private","id":10939086,"participants_count":2,"stats":{"latest_reply_at":"2013/03/14 20:24:27 +0000","shares":0,"first_reply_at":"2013/03/14 20:24:27 +0000","latest_reply_id":10939089,"first_reply_id":10939089,"updates":2},"has_attachments":false,"web_url":"https://www.yammer.com/yammer-inc.com/#/Threads/show?threadId=10939086","participants":[{"id":1841933,"type":"user"}],"thread_starter_id":10939086,"attachments_meta":{"more_files":false,"more_images":false},"type":"thread","references":[{"id":1841933,"presence":{"client":"Web","status":"online"},"web_url":"https://www.yammer.com/yammer-inc.com/users/kmutyaba","activated_at":"2012/01/23 17:01:02 +0000","state":"active","stats":{"following":60,"followers":82,"updates":1612},"type":"user","name":"kmutyaba","job_title":"Web dev","mugshot_url":"https://mug0.staging.assets-yammer.com/mugshot/images/48x48/c2QF5GN-5WsGdPGL7lGfrr6lP4kljdCj","mugshot_url_template":"https://mug0.staging.assets-yammer.com/mugshot/images/{width}x{height}/c2QF5GN-5WsGdPGL7lGfrr6lP4kljdCj","url":"https://www.yammer.com/api/v1/users/1841933","full_name":"Kevin Mutyaba"}],"url":"https://www.yammer.com/api/v1/messages/in_thread/10939086"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"has_attachments":false,"stats":{"shares":0,"first_reply_id":22,"latest_reply_at":"2013/04/06 17:05:46 +0000","latest_reply_id":25,"updates":2,"first_reply_at":"2013/04/06 17:05:46 +0000"},"attachments_meta":{"more_images":false,"more_files":false},"topics":[],"thread_starter_id":22,"url":"https://www.staging.yammer.com/api/v1/messages/in_thread/22","web_url":"https://www.yammer.com/yammer-inc.com/#/Threads/show?threadId=22","privacy":"public","attachments":[],"direct_message":false,"references":[],"type":"thread","id":22,"participants":[{"id":1841933,"type":"user"},{"id":225553,"type":"user"}],"participants_count":2}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"has_attachments":false,"stats":{"shares":0,"first_reply_id":11,"latest_reply_at":"2013/04/06 17:05:46 +0000","latest_reply_id":13,"updates":2,"first_reply_at":"2013/04/06 17:05:46 +0000"},"attachments_meta":{"more_images":false,"more_files":false},"topics":[],"thread_starter_id":11,"url":"https://www.staging.yammer.com/api/v1/messages/in_thread/11","web_url":"https://www.yammer.com/yammer-inc.com/#/Threads/show?threadId=11","privacy":"public","attachments":[],"direct_message":false,"references":[],"type":"thread","id":11,"participants":[{"id":1841933,"type":"user"},{"id":115553,"type":"user"}],"participants_count":2}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"last_name":"Smith","network_domains":["yammer-inc.com"],"timezone":"Pacific Time (US & Canada)","id":2,"expertise":"","birth_date":"","contact":{"im":{"username":"","provider":"aim"},"has_fake_email":false,"email_addresses":[{"address":"jsmith@yammer-inc.com","type":"primary"}],"phone_numbers":[{"number":"6616007618","type":"mobile"}]},"interests":"","verified_admin":"false","first_name":"John","guid":null,"web_preferences":{"dismissed_feed_tooltip":false,"show_full_names":"true","dismissed_invite_tooltip":true,"network_settings":{"admin_can_delete_messages":"true","allow_external_sharing":true,"message_prompt":"What are you working on?","show_communities_directory":true,"allow_yammer_apps":true,"allow_inline_document_view":true,"enable_private_messages":true,"allow_attachments":"true","enable_chat":true,"allow_inline_video":true,"enable_groups":true},"dismissed_profile_prompt":true,"sticky_my_feed":false,"enter_does_not_submit_message":"true","dismissed_invite_tooltip_at":"2012/09/26 22:43:29 +0000","home_tabs":[{"feed_description":"This feed shows RSS messages you're following.","select_name":"RSS","name":"RSS","type":"followed_bots","ordering_index":"8","url":"https://www.staging.yammer.com/api/v1/messages/followed_bots"},{"group_id":1,"feed_description":"This feed shows messages in this group.","select_name":"Yammer TIME!","name":"Yammer TIME!","type":"group","ordering_index":"46","private":false,"url":"https://www.staging.yammer.com/api/v1/messages/in_group/997"}],"absolute_timestamps":"false","enable_chat":"true","dismissed_apps_tooltip":true,"threaded_mode":"true","prescribed_my_feed":"algo","dismissed_group_tooltip":false,"preferred_my_feed":"following"},"network_id":1,"location":"San Francisco","admin":"false","can_broadcast":"false","external_urls":[],"significant_other":"","stats":{"following":4,"followers":5,"updates":3},"state":"active","activated_at":"2012/01/23 17:01:02 +0000","web_url":"https://www.staging.yammer.com/yammer-inc.com/users/jsmith","schools":[],"name":"jsmith","kids_names":"","follow_general_messages":false,"network_name":"Yammer Staging","type":"user","mugshot_url":"https://mug0.staging.assets-yammer.com/mugshot/images/48x48/c2QF5GN-5WsGdPGL7lGfrr6lP4kljdCj","show_ask_for_photo":false,"job_title":"Web dev","summary":"","department":"Engineering","url":"https://www.staging.yammer.com/api/v1/users/1841933","mugshot_url_template":"https://mug0.staging.assets-yammer.com/mugshot/images/{width}x{height}/c2QF5GN-5WsGdPGL7lGfrr6lP4kljdCj","previous_companies":[],"settings":{"xdr_proxy":"https://stagexdrproxy.yammer.com"},"hire_date":null,"full_name":"John Smith"}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require 'yammer/identity_map'
|
3
|
+
|
4
|
+
describe Yammer::IdentityMap do
|
5
|
+
|
6
|
+
subject { Yammer::IdentityMap.new }
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
subject.purge!
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'after initialization' do
|
13
|
+
describe '#size' do
|
14
|
+
it 'should be zero' do
|
15
|
+
expect(subject.size).to eq 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#get' do
|
20
|
+
context 'with string parameter' do
|
21
|
+
it 'should return nil' do
|
22
|
+
expect(subject.get(:key)).to eq nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with symbol parameter' do
|
27
|
+
it 'should return nil' do
|
28
|
+
expect(subject.get('key')).to eq nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with data' do
|
35
|
+
describe '#put' do
|
36
|
+
context 'with nil key' do
|
37
|
+
it 'should throw exception' do
|
38
|
+
expect { subject.put(nil, 'value') }.to raise_error(Yammer::IdentityMap::InvalidKeyError)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with empty string' do
|
43
|
+
it 'should throw exception' do
|
44
|
+
expect { subject.put('', 'value') }.to raise_error(Yammer::IdentityMap::InvalidKeyError)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should store new value' do
|
49
|
+
subject.put('user_1', 'smith')
|
50
|
+
expect(subject.size).to eq 1
|
51
|
+
expect(subject.get('user_1')).to eq 'smith'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should overwrite existing value' do
|
55
|
+
subject.put('user_1', 'smith')
|
56
|
+
subject.put('user_1', 'john')
|
57
|
+
expect(subject.size).to eq 1
|
58
|
+
expect(subject.get('user_1')).to eq 'john'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#get' do
|
63
|
+
context 'with nil key' do
|
64
|
+
it 'should throw exception' do
|
65
|
+
expect(subject.get(nil)).to eq nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with empty string' do
|
70
|
+
it 'should throw exception' do
|
71
|
+
expect(subject.get('')).to eq nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with valid key' do
|
76
|
+
it 'should return a value' do
|
77
|
+
subject.put('user_1', 'smith')
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with valid key and default value' do
|
82
|
+
it 'should return default' do
|
83
|
+
subject.put('user_1', 'smith')
|
84
|
+
expect(subject.get('user_1', 'test')).to eq 'smith'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'with invalid key and default value' do
|
89
|
+
it 'should return default' do
|
90
|
+
expect(subject.get('user_1', 'test')).to eq 'test'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#purge!' do
|
97
|
+
before do
|
98
|
+
subject.put('user_1', 'smith')
|
99
|
+
subject.put('user_2', 'john')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'empties the map' do
|
103
|
+
expect(subject.size).to eq 2
|
104
|
+
subject.purge!
|
105
|
+
expect(subject.size).to eq 0
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|