octoparts 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c89229186c51d5af46ce589a692f8f6b5c0dd90
4
- data.tar.gz: f4d20f88953cb2745ba466c14fc1d7868a6e84cc
3
+ metadata.gz: 317c9ff049a5f765301e3565e3d0950cdd4b10bd
4
+ data.tar.gz: 08f78bb01fc87dd29220192f43900e0947805409
5
5
  SHA512:
6
- metadata.gz: 6a00384c08c9c36452d2e20b72faf9994f02de625ce6f067298da61a74740dcb3522395f23de86c2ab48c51a5d910f659c255fa768ea28096cbd511be9dd5d37
7
- data.tar.gz: 654023d75c66bb1c392cf5748b0061f88563497c089e3432c916162cf479f3af444277e377a818b68ff5daf2943459c57995f278b3c9c04c84e98aaa14053641
6
+ metadata.gz: 1e6dad732918d9f8c14ce0cbf4a0f0ab333257da067ee42f73667b111483939867311da3925a7ae052e8feb0c6b88cb73eea03cbe62560ba567afe01edb72107
7
+ data.tar.gz: 5a80bc14ed1264a540b63f329ab0e8a88c6ca0ffae534534dbedb7f8074f370a9d2442802bf6087a98dc91510ec90c4e19a7ac8380f1b42c2c0cd75d0c9573df
data/README.md CHANGED
@@ -70,6 +70,12 @@ aggregate_request = Octoparts.build_aggregate_request do
70
70
  end
71
71
  response = client.invoke(aggregate_request)
72
72
 
73
+ # cache invalidation
74
+ ## post /octoparts/2/cache/invalidate/part/echo/fooValue/test
75
+ client.invalidate_cache('echo', param_name: 'fooValue', param_value: 'test')
76
+
77
+ ## post /octoparts/2/cache/invalidate/cache-group/echo_group/params/fooValue
78
+ client.invalidate_cache_group('echo_group', param_value: 'fooValue')
73
79
  ```
74
80
 
75
81
  ## Contributing
@@ -21,7 +21,9 @@ module Octoparts
21
21
  process(:post, path, {}, body, headers)
22
22
  end
23
23
 
24
- # TODO: doc
24
+ # Post an AggregateRequest and return AggregateResponse.
25
+ # @param [Octoparts::Model::AggregateRequest, Hash] params aggregate request
26
+ # @return [Octoparts::Response] response object
25
27
  def invoke(params)
26
28
  body = create_request_body(params)
27
29
  headers = { content_type: 'application/json' }
@@ -3,8 +3,11 @@ module Octoparts
3
3
  class PartRequest
4
4
  attr_accessor :part_id, :id, :params
5
5
 
6
+ def initialize
7
+ @params = []
8
+ end
9
+
6
10
  def add_param(key, value)
7
- @params ||= []
8
11
  @params << Octoparts::Model::PartRequestParam.create(key, value)
9
12
  self
10
13
  end
@@ -1,3 +1,3 @@
1
1
  module Octoparts
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:9000/octoparts/2/cache/invalidate/cache-group/echo_group/parts
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Length:
13
+ - '0'
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - text/plain; charset=utf-8
25
+ Content-Length:
26
+ - '39'
27
+ body:
28
+ encoding: UTF-8
29
+ string: 'OK: invalidated the following: Vector()'
30
+ http_version:
31
+ recorded_at: Sun, 11 Jan 2015 08:25:26 GMT
32
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:9000/octoparts/2/cache/invalidate/cache-group/echo_group/params/fooValue
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Length:
13
+ - '0'
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - text/plain; charset=utf-8
25
+ Content-Length:
26
+ - '47'
27
+ body:
28
+ encoding: UTF-8
29
+ string: 'OK: invalidated the following: Vector(fooValue)'
30
+ http_version:
31
+ recorded_at: Sun, 11 Jan 2015 08:25:26 GMT
32
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:9000/octoparts/2/cache/invalidate/part/echo
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Length:
13
+ - '0'
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - text/plain; charset=utf-8
25
+ Content-Length:
26
+ - '2'
27
+ body:
28
+ encoding: UTF-8
29
+ string: OK
30
+ http_version:
31
+ recorded_at: Sat, 10 Jan 2015 12:21:49 GMT
32
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://localhost:9000/octoparts/2/cache/invalidate/part/echo/fooValue/test
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Content-Length:
13
+ - '0'
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Type:
24
+ - text/plain; charset=utf-8
25
+ Content-Length:
26
+ - '2'
27
+ body:
28
+ encoding: UTF-8
29
+ string: OK
30
+ http_version:
31
+ recorded_at: Sat, 10 Jan 2015 12:24:16 GMT
32
+ recorded_with: VCR 2.9.3
data/test/test_client.rb CHANGED
@@ -115,6 +115,42 @@ class TestClient < Test::Unit::TestCase
115
115
  end
116
116
  end
117
117
 
118
+ sub_test_case "#invalidate_cache" do
119
+ test "post /invalidate/part/PART_ID" do
120
+ VCR.use_cassette 'invalidate_cache_with_part_id' do
121
+ stub_request(:post, 'localhost:9000')
122
+ @client.invalidate_cache('echo')
123
+ assert_requested(:post, 'http://localhost:9000/octoparts/2/cache/invalidate/part/echo')
124
+ end
125
+ end
126
+
127
+ test "post /invalidate/part/PART_ID/PARAM_NAME/PARAM_VALUE" do
128
+ VCR.use_cassette 'invalidate_cache_with_part_id_and_key_value' do
129
+ stub_request(:post, 'localhost:9000')
130
+ @client.invalidate_cache('echo', param_name: 'fooValue', param_value: 'test')
131
+ assert_requested(:post, 'http://localhost:9000/octoparts/2/cache/invalidate/part/echo/fooValue/test')
132
+ end
133
+ end
134
+ end
135
+
136
+ sub_test_case "#invalidate_cache_group" do
137
+ test "post /invalidate/cache-group/GROUP_NAME/parts" do
138
+ VCR.use_cassette 'invalidate_cache_group_with_group_name' do
139
+ stub_request(:post, 'localhost:9000')
140
+ @client.invalidate_cache_group('echo_group')
141
+ assert_requested(:post, 'http://localhost:9000/octoparts/2/cache/invalidate/cache-group/echo_group/parts')
142
+ end
143
+ end
144
+
145
+ test "post /invalidate/cache-group/GROUP_NAME/params/PARAM_VALUE" do
146
+ VCR.use_cassette 'invalidate_cache_group_with_param_value' do
147
+ stub_request(:post, 'localhost:9000')
148
+ @client.invalidate_cache_group('echo_group', param_value: 'fooValue')
149
+ assert_requested(:post, 'http://localhost:9000/octoparts/2/cache/invalidate/cache-group/echo_group/params/fooValue')
150
+ end
151
+ end
152
+ end
153
+
118
154
  sub_test_case "timeout" do
119
155
  setup do
120
156
  @endpoint = Octoparts.configuration.endpoint
@@ -148,4 +184,13 @@ class TestClient < Test::Unit::TestCase
148
184
  end
149
185
  end
150
186
  end
187
+
188
+ sub_test_case "error case" do
189
+ test "500 error" do
190
+ stub_request(:any, 'localhost:9000/500').to_return(status: 500, body: 'NG', headers: { 'Content-Length' => 2})
191
+ assert_raise Octoparts::ServerError do
192
+ Octoparts::Client.new(timeout_sec: 0).get('/500')
193
+ end
194
+ end
195
+ end
151
196
  end
@@ -5,8 +5,19 @@ class TestOctoparts < Test::Unit::TestCase
5
5
  refute_nil ::Octoparts::VERSION
6
6
  end
7
7
 
8
- def test_it_does_something_useful
9
- assert { ['exist'].empty? == false }
8
+ test ".configuration" do
9
+ assert { Octoparts.configuration.class == Octoparts::Configuration }
10
+ end
11
+
12
+ sub_test_case ".configure" do
13
+ teardown do
14
+ Octoparts.configure { |c| c.open_timeout_sec = nil }
15
+ end
16
+
17
+ test "open_timeout_sec is set at Octoparts.configure" do
18
+ Octoparts.configure { |c| c.open_timeout_sec = 2 }
19
+ assert { Octoparts.configuration.open_timeout_sec == 2 }
20
+ end
10
21
  end
11
22
 
12
23
  test "Octoparts.create_aggregate_request" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octoparts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takayuki Matsubara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-10 00:00:00.000000000 Z
11
+ date: 2015-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: representable
@@ -185,6 +185,10 @@ files:
185
185
  - lib/octoparts/response.rb
186
186
  - lib/octoparts/version.rb
187
187
  - octoparts.gemspec
188
+ - test/fixtures/vcr/invalidate_cache_group_with_group_name.yml
189
+ - test/fixtures/vcr/invalidate_cache_group_with_param_value.yml
190
+ - test/fixtures/vcr/invalidate_cache_with_part_id.yml
191
+ - test/fixtures/vcr/invalidate_cache_with_part_id_and_key_value.yml
188
192
  - test/fixtures/vcr/invoke_example.yml
189
193
  - test/fixtures/vcr/invoke_with_2_requests.yml
190
194
  - test/fixtures/vcr/invoke_with_aggregate_request.yml
@@ -219,6 +223,10 @@ signing_key:
219
223
  specification_version: 4
220
224
  summary: Ruby client for the Octoparts API
221
225
  test_files:
226
+ - test/fixtures/vcr/invalidate_cache_group_with_group_name.yml
227
+ - test/fixtures/vcr/invalidate_cache_group_with_param_value.yml
228
+ - test/fixtures/vcr/invalidate_cache_with_part_id.yml
229
+ - test/fixtures/vcr/invalidate_cache_with_part_id_and_key_value.yml
222
230
  - test/fixtures/vcr/invoke_example.yml
223
231
  - test/fixtures/vcr/invoke_with_2_requests.yml
224
232
  - test/fixtures/vcr/invoke_with_aggregate_request.yml