gds-api-adapters 4.1.0 → 4.1.1
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/lib/gds_api/base.rb +1 -0
- data/lib/gds_api/test_helpers/content_api.rb +3 -1
- data/lib/gds_api/test_helpers/imminence.rb +4 -1
- data/lib/gds_api/test_helpers/licence_application.rb +3 -1
- data/lib/gds_api/test_helpers/panopticon.rb +3 -1
- data/lib/gds_api/test_helpers/publisher.rb +3 -1
- data/lib/gds_api/version.rb +1 -1
- data/test/content_api_test.rb +8 -8
- data/test/test_helper.rb +5 -0
- metadata +4 -4
data/lib/gds_api/base.rb
CHANGED
@@ -5,7 +5,9 @@ require_relative 'content_api/artefact_stub'
|
|
5
5
|
module GdsApi
|
6
6
|
module TestHelpers
|
7
7
|
module ContentApi
|
8
|
-
|
8
|
+
# Generally true. If you are initializing the client differently,
|
9
|
+
# you could redefine/override the constant or stub directly.
|
10
|
+
CONTENT_API_ENDPOINT = Plek.current.find('contentapi')
|
9
11
|
|
10
12
|
# Takes an array of slugs, or hashes with section details (including a slug).
|
11
13
|
# Will stub out content_api calls for tags of type section to return these sections
|
@@ -3,7 +3,10 @@ require 'gds_api/test_helpers/json_client_helper'
|
|
3
3
|
module GdsApi
|
4
4
|
module TestHelpers
|
5
5
|
module Imminence
|
6
|
-
|
6
|
+
# Generally true. If you are initializing the client differently,
|
7
|
+
# you could redefine/override the constant or stub directly.
|
8
|
+
IMMINENCE_API_HOST = URI.parse(Plek.current.find('imminence')).host
|
9
|
+
|
7
10
|
def imminence_has_places(latitude, longitude, details)
|
8
11
|
response = JSON.dump(details['details'])
|
9
12
|
|
@@ -3,7 +3,9 @@ require 'gds_api/test_helpers/json_client_helper'
|
|
3
3
|
module GdsApi
|
4
4
|
module TestHelpers
|
5
5
|
module LicenceApplication
|
6
|
-
|
6
|
+
# Generally true. If you are initializing the client differently,
|
7
|
+
# you could redefine/override the constant or stub directly.
|
8
|
+
LICENCE_APPLICATION_ENDPOINT = Plek.current.find("licensify")
|
7
9
|
|
8
10
|
def licence_exists(identifier, licence)
|
9
11
|
licence = licence.to_json unless licence.is_a?(String)
|
@@ -3,7 +3,9 @@ require 'gds_api/test_helpers/json_client_helper'
|
|
3
3
|
module GdsApi
|
4
4
|
module TestHelpers
|
5
5
|
module Panopticon
|
6
|
-
|
6
|
+
# Generally true. If you are initializing the client differently,
|
7
|
+
# you could redefine/override the constant or stub directly.
|
8
|
+
PANOPTICON_ENDPOINT = Plek.current.find('panopticon')
|
7
9
|
|
8
10
|
def stringify_hash_keys(input_hash)
|
9
11
|
input_hash.inject({}) do |options, (key, value)|
|
@@ -3,7 +3,9 @@ require 'gds_api/test_helpers/json_client_helper'
|
|
3
3
|
module GdsApi
|
4
4
|
module TestHelpers
|
5
5
|
module Publisher
|
6
|
-
|
6
|
+
# Generally true. If you are initializing the client differently,
|
7
|
+
# you could redefine/override the constant or stub directly.
|
8
|
+
PUBLISHER_ENDPOINT = Plek.current.find("publisher")
|
7
9
|
|
8
10
|
def publication_exists(details, options = {})
|
9
11
|
json = JSON.dump(details)
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_api_test.rb
CHANGED
@@ -6,7 +6,7 @@ describe GdsApi::ContentApi do
|
|
6
6
|
include GdsApi::TestHelpers::ContentApi
|
7
7
|
|
8
8
|
before do
|
9
|
-
@base_api_url =
|
9
|
+
@base_api_url = Plek.current.find("contentapi")
|
10
10
|
@api = GdsApi::ContentApi.new(@base_api_url)
|
11
11
|
end
|
12
12
|
|
@@ -15,7 +15,7 @@ describe GdsApi::ContentApi do
|
|
15
15
|
content_api_has_root_sections(["crime"])
|
16
16
|
response = @api.sections
|
17
17
|
first_section = response["results"][0]
|
18
|
-
assert_equal "
|
18
|
+
assert_equal "#{@base_api_url}/tags/crime.json", first_section["id"]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -23,14 +23,14 @@ describe GdsApi::ContentApi do
|
|
23
23
|
it "should show the artefact" do
|
24
24
|
content_api_has_an_artefact("devolution-uk")
|
25
25
|
response = @api.artefact("devolution-uk")
|
26
|
-
assert_equal "
|
26
|
+
assert_equal "#{@base_api_url}/devolution-uk.json", response["id"]
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should be able to fetch unpublished editions when authenticated" do
|
30
30
|
api = GdsApi::ContentApi.new(@base_api_url, { bearer_token: 'MY_BEARER_TOKEN' })
|
31
31
|
content_api_has_unpublished_artefact("devolution-uk", 3)
|
32
32
|
response = api.artefact("devolution-uk", edition: 3)
|
33
|
-
assert_equal "
|
33
|
+
assert_equal "#{@base_api_url}/devolution-uk.json", response["id"]
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should raise an exception if no bearer token is used when fetching unpublished editions" do
|
@@ -304,19 +304,19 @@ describe GdsApi::ContentApi do
|
|
304
304
|
|
305
305
|
assert_requested :get, %r{\A#{@base_api_url}/business_support_schemes\.json}, :times => 2
|
306
306
|
|
307
|
-
first_batch = ids[0..
|
307
|
+
first_batch = ids[0..191]
|
308
308
|
assert_requested :get, "#{@base_api_url}/business_support_schemes.json?identifiers=#{first_batch.join(',')}"
|
309
|
-
second_batch = ids[
|
309
|
+
second_batch = ids[192..299]
|
310
310
|
assert_requested :get, "#{@base_api_url}/business_support_schemes.json?identifiers=#{second_batch.join(',')}"
|
311
311
|
end
|
312
312
|
|
313
313
|
it "should merge the responses into a single GdsApi::Response" do
|
314
314
|
ids = (1..300).map {|n| sprintf "%09d", n } # each id is 9 chars long
|
315
|
-
first_batch = ids[0..
|
315
|
+
first_batch = ids[0..191]
|
316
316
|
stub_request(:get, "#{@base_api_url}/business_support_schemes.json").
|
317
317
|
with(:query => {"identifiers" => first_batch.join(',')}).
|
318
318
|
to_return(:status => 200, :body => api_response_for_results(first_batch).to_json) # We're stubbing response that just return the requested ids
|
319
|
-
second_batch = ids[
|
319
|
+
second_batch = ids[192..299]
|
320
320
|
stub_request(:get, "#{@base_api_url}/business_support_schemes.json").
|
321
321
|
with(:query => {"identifiers" => second_batch.join(',')}).
|
322
322
|
to_return(:status => 200, :body => api_response_for_results(second_batch).to_json)
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Ensure that in tests, we get a consistent domain back from Plek < 1.0.0
|
2
|
+
# Without this, content API tests re chunking of requests with long URLs would
|
3
|
+
# pass/fail in dev/CI.
|
4
|
+
ENV['RACK_ENV'] = "test"
|
5
|
+
|
1
6
|
require 'bundler'
|
2
7
|
Bundler.setup :default, :development, :test
|
3
8
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 4.1.
|
5
|
+
version: 4.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Stewart
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-27 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: plek
|
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
214
|
requirements:
|
215
215
|
- - ">="
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
hash:
|
217
|
+
hash: 3713358432051665576
|
218
218
|
segments:
|
219
219
|
- 0
|
220
220
|
version: "0"
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
requirements:
|
224
224
|
- - ">="
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
-
hash:
|
226
|
+
hash: 3713358432051665576
|
227
227
|
segments:
|
228
228
|
- 0
|
229
229
|
version: "0"
|