Remove deprecated code
diff --git a/spec/predictionio_spec.rb b/spec/predictionio_spec.rb
index 911dc93..b7f2045 100644
--- a/spec/predictionio_spec.rb
+++ b/spec/predictionio_spec.rb
@@ -1,7 +1,6 @@
require 'predictionio'
require 'spec_helper'
-client = PredictionIO::Client.new('foobar', 10, 'http://fakeapi.com:8000')
event_client = PredictionIO::EventClient.new(1, 'http://fakeapi.com:8000', 10)
engine_client = PredictionIO::EngineClient.new('http://fakeapi.com:8000', 10)
@@ -50,92 +49,4 @@
expect(predictions).to eq('iids' => %w(dead beef))
end
end
-
- describe 'Users API' do
- it 'create_user should create a user' do
- response = client.create_user('foo')
- expect(response).to_not raise_error
- end
- it 'get_user should get a user' do
- response = client.get_user('foo')
- expect(response).to eq('pio_uid' => 'foo')
- end
- it 'delete_user should delete a user' do
- response = client.delete_user('foo')
- expect(response).to_not raise_error
- end
- end
-
- describe 'Items API' do
- it 'create_item should create a item' do
- response = client.create_item('bar', %w(dead beef))
- expect(response).to_not raise_error
- end
- it 'get_item should get a item' do
- response = client.get_item('bar')
- expect(response).to eq('pio_iid' => 'bar',
- 'pio_itypes' => %w(dead beef))
- end
- it 'delete_item should delete a item' do
- response = client.delete_item('bar')
- expect(response).to_not raise_error
- end
- end
-
- describe 'U2I API' do
- it 'record_action_on_item should record an action' do
- client.identify('foo')
- response = client.record_action_on_item('view', 'bar')
- expect(response).to_not raise_error
- end
- end
-
- describe 'Item Recommendation API' do
- it 'provides recommendations to a user without attributes' do
- client.identify('foo')
- response = client.get_itemrec_top_n('itemrec-engine', 10)
- expect(response).to eq(%w(x y z))
- end
- it 'provides recommendations to a user with attributes' do
- client.identify('foo')
- response = client.get_itemrec_top_n('itemrec-engine', 10,
- 'pio_attributes' => 'name')
- expect(response).to eq([
- { 'pio_iid' => 'x', 'name' => 'a' },
- { 'pio_iid' => 'y', 'name' => 'b' },
- { 'pio_iid' => 'z', 'name' => 'c' }])
- end
- end
-
- describe 'Item Rank API' do
- it 'provides ranking to a user without attributes' do
- client.identify('foo')
- response = client.get_itemrank_ranked('itemrank-engine', %w(y z x))
- expect(response).to eq(%w(x y z))
- end
- it 'provides ranking to a user with attributes' do
- client.identify('foo')
- response = client.get_itemrank_ranked('itemrank-engine', %w(y x z),
- 'pio_attributes' => 'name')
- expect(response).to eq([
- { 'pio_iid' => 'x', 'name' => 'a' },
- { 'pio_iid' => 'y', 'name' => 'b' },
- { 'pio_iid' => 'z', 'name' => 'c' }])
- end
- end
-
- describe 'Item Similarity API' do
- it 'provides similarities to an item without attributes' do
- response = client.get_itemsim_top_n('itemsim-engine', 'bar', 10)
- expect(response).to eq(%w(x y z))
- end
- it 'provides similarities to an item with attributes' do
- response = client.get_itemsim_top_n('itemsim-engine', 'bar', 10,
- 'pio_attributes' => 'name')
- expect(response).to eq([
- { 'pio_iid' => 'x', 'name' => 'a' },
- { 'pio_iid' => 'y', 'name' => 'b' },
- { 'pio_iid' => 'z', 'name' => 'c' }])
- end
- end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 19d9d32..917ce65 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -8,41 +8,41 @@
RSpec.configure do |config|
config.before(:each) do
# Events API
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: 'register',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: 'register',
entityType: 'user', entityId: 'foobar'))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef00'))
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: '$set',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: '$set',
entityType: 'pio_user', entityId: 'foobar'))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef01'))
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: '$unset',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: '$unset',
entityType: 'pio_user', entityId: 'foobar',
properties: { bar: 'baz' }))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef02'))
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: '$set',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: '$set',
entityType: 'pio_item', entityId: 'foobar'))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef03'))
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: '$unset',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: '$unset',
entityType: 'pio_item', entityId: 'foobar',
properties: { bar: 'baz' }))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef04'))
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: 'greet',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: 'greet',
entityType: 'pio_user', entityId: 'foobar',
targetEntityType: 'pio_item',
targetEntityId: 'barbaz',
properties: { dead: 'beef' }))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef05'))
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: '$delete',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: '$delete',
entityType: 'pio_user', entityId: 'foobar'))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef06'))
- stub_request(:post, 'http://fakeapi.com:8000/events.json')
- .with(body: hash_including(appId: 1, event: '$delete',
+ stub_request(:post, 'http://fakeapi.com:8000/events.json?accessKey=1')
+ .with(body: hash_including(event: '$delete',
entityType: 'pio_item', entityId: 'foobar'))
.to_return(status: 201, body: JSON.generate(eventId: 'deadbeef07'))
@@ -51,92 +51,5 @@
.with(body: { uid: 'foobar' })
.to_return(status: 200, body: JSON.generate(iids: %w(dead beef)),
headers: {})
-
- # Users API
- stub_request(:post, 'http://fakeapi.com:8000/users.json')
- .with(body: { pio_appkey: 'foobar', pio_uid: 'foo' })
- .to_return(status: 201, body: '', headers: {})
- stub_request(:get, 'http://fakeapi.com:8000/users/foo.json')
- .with(query: hash_including(pio_appkey: 'foobar'))
- .to_return(status: 200, body: JSON.generate(pio_uid: 'foo'), headers: {})
- stub_request(:delete, 'http://fakeapi.com:8000/users/foo.json')
- .with(query: hash_including(pio_appkey: 'foobar'))
- .to_return(status: 200, body: '', headers: {})
-
- # Items API
- stub_request(:post, 'http://fakeapi.com:8000/items.json')
- .with(body: { pio_appkey: 'foobar', pio_iid: 'bar',
- pio_itypes: 'dead,beef' })
- .to_return(status: 201, body: '', headers: {})
- stub_request(:get, 'http://fakeapi.com:8000/items/bar.json')
- .with(query: hash_including(pio_appkey: 'foobar'))
- .to_return(status: 200,
- body: JSON.generate(pio_iid: 'bar', pio_itypes: %w(dead beef)),
- headers: {})
- stub_request(:delete, 'http://fakeapi.com:8000/items/bar.json')
- .with(query: hash_including(pio_appkey: 'foobar'))
- .to_return(status: 200, body: '', headers: {})
-
- # U2I Actions API
- stub_request(:post, 'http://fakeapi.com:8000/actions/u2i.json')
- .with(body: { pio_action: 'view', pio_appkey: 'foobar', pio_iid: 'bar',
- pio_uid: 'foo' })
- .to_return(status: 201, body: '', headers: {})
-
- # Item Recommendation API
- stub_request(
- :get,
- 'http://fakeapi.com:8000/engines/itemrec/itemrec-engine/topn.json')
- .with(query: hash_including(pio_appkey: 'foobar', pio_n: '10',
- pio_uid: 'foo'))
- .to_return(status: 200, body: JSON.generate(pio_iids: %w(x y z)),
- headers: {})
-
- stub_request(
- :get,
- 'http://fakeapi.com:8000/engines/itemrec/itemrec-engine/topn.json')
- .with(query: hash_including(pio_appkey: 'foobar', pio_n: '10',
- pio_uid: 'foo', pio_attributes: 'name'))
- .to_return(status: 200,
- body: JSON.generate(pio_iids: %w(x y z), name: %w(a b c)),
- headers: {})
-
- # Item Recommendation API
- stub_request(
- :get,
- 'http://fakeapi.com:8000/engines/itemrank/itemrank-engine/ranked.json')
- .with(query: hash_including(pio_appkey: 'foobar', pio_iids: 'y,z,x',
- pio_uid: 'foo'))
- .to_return(status: 200, body: JSON.generate(pio_iids: %w(x y z)),
- headers: {})
-
- stub_request(
- :get,
- 'http://fakeapi.com:8000/engines/itemrank/itemrank-engine/ranked.json')
- .with(query: hash_including(pio_appkey: 'foobar', pio_iids: 'y,x,z',
- pio_uid: 'foo', pio_attributes: 'name'))
- .to_return(status: 200,
- body: JSON.generate(pio_iids: %w(x y z), name: %w(a b c)),
- headers: {})
-
- # Item Similarity API
- stub_request(
- :get,
- 'http://fakeapi.com:8000/engines/itemsim/itemsim-engine/topn.json')
- .with(query: hash_including(pio_appkey: 'foobar', pio_n: '10',
- pio_iid: 'bar'))
- .to_return(status: 200,
- body: JSON.generate(pio_iids: %w(x y z)),
- headers: {})
-
- stub_request(
- :get,
- 'http://fakeapi.com:8000/engines/itemsim/itemsim-engine/topn.json')
- .with(query: hash_including(pio_appkey: 'foobar', pio_n: '10',
- pio_iid: 'bar', pio_attributes: 'name'))
- .to_return(status: 200,
- body: JSON.generate('pio_iids' => %w(x y z),
- 'name' => %w(a b c)),
- headers: {})
end
end