gds-api-adapters 38.1.0 → 39.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/test_helpers/need_api.rb +0 -15
- data/lib/gds_api/test_helpers/organisations.rb +5 -0
- data/lib/gds_api/version.rb +1 -1
- metadata +3 -103
- data/test/asset_manager_test.rb +0 -94
- data/test/business_support_api_test.rb +0 -45
- data/test/content_api_test.rb +0 -712
- data/test/content_store_test.rb +0 -55
- data/test/email_alert_api_test.rb +0 -189
- data/test/fixtures/finder_api/cma-case-schema.json +0 -103
- data/test/fixtures/hello.txt +0 -1
- data/test/fixtures/new_policies_for_dwp.json +0 -298
- data/test/fixtures/no_services_and_info_data_found_fixture.json +0 -14
- data/test/fixtures/old_policies_for_dwp.json +0 -413
- data/test/fixtures/services_and_info_fixture.json +0 -73
- data/test/fixtures/sub_sector_organisations.json +0 -57
- data/test/fixtures/world_organisations_australia.json +0 -490
- data/test/gds_api_base_test.rb +0 -110
- data/test/gov_uk_delivery_test.rb +0 -67
- data/test/govuk_headers_test.rb +0 -30
- data/test/helpers_test.rb +0 -23
- data/test/imminence_api_test.rb +0 -196
- data/test/json_client_test.rb +0 -879
- data/test/licence_application_api_test.rb +0 -196
- data/test/list_response_test.rb +0 -189
- data/test/local_links_manager_api_test.rb +0 -236
- data/test/mapit_test.rb +0 -117
- data/test/maslow_test.rb +0 -12
- data/test/middleware/govuk_header_sniffer_test.rb +0 -18
- data/test/need_api_test.rb +0 -345
- data/test/organisations_api_test.rb +0 -58
- data/test/panopticon_registerer_test.rb +0 -118
- data/test/panopticon_test.rb +0 -190
- data/test/pp_data_in_test.rb +0 -52
- data/test/pp_data_out_test.rb +0 -24
- data/test/publishing_api/special_route_publisher_test.rb +0 -104
- data/test/publishing_api_test.rb +0 -186
- data/test/publishing_api_v2/get_expanded_links_test.rb +0 -85
- data/test/publishing_api_v2/get_links_test.rb +0 -89
- data/test/publishing_api_v2/lookup_test.rb +0 -70
- data/test/publishing_api_v2_test.rb +0 -1649
- data/test/response_test.rb +0 -245
- data/test/router_test.rb +0 -456
- data/test/rummager_helpers_test.rb +0 -20
- data/test/rummager_test.rb +0 -150
- data/test/support_api_test.rb +0 -189
- data/test/support_test.rb +0 -95
- data/test/test_helper.rb +0 -55
- data/test/test_helpers/email_alert_api_test.rb +0 -24
- data/test/test_helpers/pact_helper.rb +0 -13
- data/test/test_helpers/panopticon_test.rb +0 -44
- data/test/test_helpers/publishing_api_test.rb +0 -129
- data/test/test_helpers/publishing_api_v2_test.rb +0 -170
- data/test/worldwide_api_test.rb +0 -82
@@ -1,196 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "gds_api/licence_application"
|
3
|
-
require "gds_api/test_helpers/licence_application"
|
4
|
-
|
5
|
-
class LicenceApplicationApiTest < Minitest::Test
|
6
|
-
include GdsApi::TestHelpers::LicenceApplication
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@core_url = LICENCE_APPLICATION_ENDPOINT
|
10
|
-
end
|
11
|
-
|
12
|
-
def api
|
13
|
-
GdsApi::LicenceApplication.new LICENCE_APPLICATION_ENDPOINT
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_should_not_be_nil
|
17
|
-
assert_equal false, api.nil?
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_should_return_list_of_licences
|
21
|
-
stub_request(:get, "#{@core_url}/api/licences").
|
22
|
-
with(headers: GdsApi::JsonClient.default_request_headers).
|
23
|
-
to_return(status: 200,
|
24
|
-
body: <<-EOS
|
25
|
-
[
|
26
|
-
{
|
27
|
-
"code":"1324-5-1",
|
28
|
-
"name":"Land drainage consents",
|
29
|
-
"legislation":[
|
30
|
-
"Land Drainage Act 1991"
|
31
|
-
]
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"code":"695-5-1",
|
35
|
-
"name":"Skip operator licence",
|
36
|
-
"legislation":[
|
37
|
-
"Highways Act 1980, Section 139"
|
38
|
-
]
|
39
|
-
},
|
40
|
-
{
|
41
|
-
"code":"1251-4-1",
|
42
|
-
"name":"Residential care homes",
|
43
|
-
"legislation":[
|
44
|
-
"Health and Personal Social Services (Quality, Improvement and Regulation) (Northern Ireland) Order 2003"
|
45
|
-
]
|
46
|
-
}
|
47
|
-
]
|
48
|
-
EOS
|
49
|
-
)
|
50
|
-
|
51
|
-
land_drainage = {
|
52
|
-
"code" => "1324-5-1",
|
53
|
-
"name" => "Land drainage consents",
|
54
|
-
"legislation" => ["Land Drainage Act 1991"],
|
55
|
-
}
|
56
|
-
|
57
|
-
assert_includes api.all_licences, land_drainage
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_should_return_error_message_if_licences_collection_not_found
|
61
|
-
stub_request(:get, "#{@core_url}/api/licences").
|
62
|
-
with(headers: GdsApi::JsonClient.default_request_headers).
|
63
|
-
to_return(status: 404,
|
64
|
-
body: "{\"error\": \"Error\"}")
|
65
|
-
|
66
|
-
assert_raises GdsApi::HTTPNotFound do
|
67
|
-
api.all_licences
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_should_return_nil_if_id_nil
|
72
|
-
assert_nil api.details_for_licence(nil)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_should_raise_if_licence_is_unrecognised
|
76
|
-
licence_does_not_exist('bloop')
|
77
|
-
|
78
|
-
assert_raises(GdsApi::HTTPNotFound) do
|
79
|
-
api.details_for_licence("bloop")
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_should_provide_full_licence_details_for_canonical_id
|
84
|
-
licence_exists('590001', "isLocationSpecific" => true, "geographicalAvailability" => %w(England Wales), "issuingAuthorities" => [])
|
85
|
-
|
86
|
-
expected = {
|
87
|
-
"isLocationSpecific" => true,
|
88
|
-
"geographicalAvailability" => %w(England Wales),
|
89
|
-
"issuingAuthorities" => []
|
90
|
-
}
|
91
|
-
|
92
|
-
assert_equal expected, api.details_for_licence("590001").to_hash
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_should_raise_for_bad_snac_code_entry
|
96
|
-
licence_does_not_exist('590001/bleep')
|
97
|
-
|
98
|
-
assert_raises(GdsApi::HTTPNotFound) do
|
99
|
-
api.details_for_licence("590001", "bleep")
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_should_raise_for_bad_licence_id_and_snac_code
|
104
|
-
licence_does_not_exist('bloop/bleep')
|
105
|
-
|
106
|
-
assert_raises(GdsApi::HTTPNotFound) do
|
107
|
-
api.details_for_licence("bloop", "bleep")
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_should_return_error_message_to_pick_a_relevant_snac_code_for_the_provided_licence_id
|
112
|
-
stub_request(:get, "#{@core_url}/api/licence/590001/sw10").
|
113
|
-
with(headers: GdsApi::JsonClient.default_request_headers).
|
114
|
-
to_return(status: 404,
|
115
|
-
body: "{\"error\": \"No authorities found for the licence 590001 and for the snacCode sw10\"}")
|
116
|
-
|
117
|
-
assert_raises(GdsApi::HTTPNotFound) do
|
118
|
-
api.details_for_licence("590001", "sw10")
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_should_return_full_licence_details_with_location_specific_information
|
123
|
-
licence_exists('866-5-1/00AA', <<-EOS
|
124
|
-
{
|
125
|
-
"isLocationSpecific":true,
|
126
|
-
"geographicalAvailability":[
|
127
|
-
"England",
|
128
|
-
"Wales"
|
129
|
-
],
|
130
|
-
"issuingAuthorities":[
|
131
|
-
{
|
132
|
-
"authorityName":"City of London",
|
133
|
-
"authorityInteractions":{
|
134
|
-
"apply":[
|
135
|
-
{
|
136
|
-
"url":"https://www.gov.uk/motor-salvage-operator-registration/city-of-london/apply-1",
|
137
|
-
"usesLicensify":true,
|
138
|
-
"description":"Application to register as a motor salvage operator",
|
139
|
-
"payment":"none"
|
140
|
-
}
|
141
|
-
],
|
142
|
-
"renew":[
|
143
|
-
{
|
144
|
-
"url":"https://www.gov.uk/motor-salvage-operator-registration/city-of-london/renew-1",
|
145
|
-
"usesLicensify":true,
|
146
|
-
"description":"Application to renew a registration as motor salvage operator",
|
147
|
-
"payment":"none"
|
148
|
-
}
|
149
|
-
],
|
150
|
-
"change":[
|
151
|
-
{
|
152
|
-
"url":"https://www.gov.uk/motor-salvage-operator-registration/city-of-london/change-1",
|
153
|
-
"usesLicensify":true,
|
154
|
-
"description":"Application to change a registration as motor salvage operator",
|
155
|
-
"payment":"none"
|
156
|
-
},
|
157
|
-
{
|
158
|
-
"url":"https://www.gov.uk/motor-salvage-operator-registration/city-of-london/change-2",
|
159
|
-
"usesLicensify":true,
|
160
|
-
"description":"Application to surrender a registration as motor salvage operator",
|
161
|
-
"payment":"none"
|
162
|
-
}
|
163
|
-
]
|
164
|
-
}
|
165
|
-
}
|
166
|
-
]
|
167
|
-
}
|
168
|
-
EOS
|
169
|
-
)
|
170
|
-
|
171
|
-
response = api.details_for_licence("866-5-1", "00AA")
|
172
|
-
|
173
|
-
assert_equal true, response["isLocationSpecific"]
|
174
|
-
|
175
|
-
assert_includes response["issuingAuthorities"][0]["authorityInteractions"]["apply"], "url" => "https://www.gov.uk/motor-salvage-operator-registration/city-of-london/apply-1",
|
176
|
-
"usesLicensify" => true,
|
177
|
-
"description" => "Application to register as a motor salvage operator",
|
178
|
-
"payment" => "none"
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_should_raise_exception_on_timeout
|
182
|
-
licence_times_out("866-5-1")
|
183
|
-
|
184
|
-
assert_raises GdsApi::TimedOutException do
|
185
|
-
api.details_for_licence("866-5-1")
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_should_raise_exception_on_api_error
|
190
|
-
licence_returns_error("866-5-1")
|
191
|
-
|
192
|
-
assert_raises GdsApi::HTTPServerError do
|
193
|
-
api.details_for_licence("866-5-1")
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
data/test/list_response_test.rb
DELETED
@@ -1,189 +0,0 @@
|
|
1
|
-
require_relative 'test_helper'
|
2
|
-
require 'gds_api/list_response'
|
3
|
-
|
4
|
-
describe GdsApi::ListResponse do
|
5
|
-
describe "accessing results" do
|
6
|
-
before :each do
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should allow Enumerable access to the results array" do
|
10
|
-
data = {
|
11
|
-
"results" => %w(foo bar baz),
|
12
|
-
"total" => 3,
|
13
|
-
"_response_info" => {
|
14
|
-
"status" => "ok",
|
15
|
-
}
|
16
|
-
}
|
17
|
-
response = GdsApi::ListResponse.new(stub(body: data.to_json), nil)
|
18
|
-
|
19
|
-
assert_equal "foo", response.first
|
20
|
-
assert_equal %w(foo bar baz), response.to_a
|
21
|
-
assert response.any?
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should handle an empty result set" do
|
25
|
-
data = {
|
26
|
-
"results" => [],
|
27
|
-
"total" => 0,
|
28
|
-
"_response_info" => {
|
29
|
-
"status" => "ok",
|
30
|
-
}
|
31
|
-
}
|
32
|
-
response = GdsApi::ListResponse.new(stub(body: data.to_json), nil)
|
33
|
-
|
34
|
-
assert_equal [], response.to_a
|
35
|
-
assert ! response.any?
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "handling pagination" do
|
40
|
-
before :each do
|
41
|
-
page_1 = {
|
42
|
-
"results" => %w(foo1 bar1),
|
43
|
-
"total" => 6,
|
44
|
-
"current_page" => 1, "pages" => 3, "page_size" => 2,
|
45
|
-
"_response_info" => {
|
46
|
-
"status" => "ok",
|
47
|
-
"links" => [
|
48
|
-
{ "href" => "http://www.example.com/2", "rel" => "next" },
|
49
|
-
{ "href" => "http://www.example.com/1", "rel" => "self" },
|
50
|
-
]
|
51
|
-
}
|
52
|
-
}
|
53
|
-
page_2 = {
|
54
|
-
"results" => %w(foo2 bar2),
|
55
|
-
"total" => 6,
|
56
|
-
"current_page" => 2, "pages" => 3, "page_size" => 2,
|
57
|
-
"_response_info" => {
|
58
|
-
"status" => "ok",
|
59
|
-
"links" => [
|
60
|
-
{ "href" => "http://www.example.com/1", "rel" => "previous" },
|
61
|
-
{ "href" => "http://www.example.com/3", "rel" => "next" },
|
62
|
-
{ "href" => "http://www.example.com/2", "rel" => "self" },
|
63
|
-
]
|
64
|
-
}
|
65
|
-
}
|
66
|
-
page_3 = {
|
67
|
-
"results" => %w(foo3 bar3),
|
68
|
-
"total" => 6,
|
69
|
-
"current_page" => 3, "pages" => 3, "page_size" => 2,
|
70
|
-
"_response_info" => {
|
71
|
-
"status" => "ok",
|
72
|
-
"links" => [
|
73
|
-
{ "href" => "http://www.example.com/2", "rel" => "previous" },
|
74
|
-
{ "href" => "http://www.example.com/3", "rel" => "self" },
|
75
|
-
]
|
76
|
-
}
|
77
|
-
}
|
78
|
-
@p1_response = stub(
|
79
|
-
body: page_1.to_json,
|
80
|
-
status: 200,
|
81
|
-
headers: {
|
82
|
-
link: '<http://www.example.com/1>; rel="self", <http://www.example.com/2>; rel="next"'
|
83
|
-
}
|
84
|
-
)
|
85
|
-
@p2_response = stub(
|
86
|
-
body: page_2.to_json,
|
87
|
-
status: 200,
|
88
|
-
headers: {
|
89
|
-
link: '<http://www.example.com/2>; rel="self", <http://www.example.com/3>; rel="next", <http://www.example.com/1>; rel="previous"'
|
90
|
-
}
|
91
|
-
)
|
92
|
-
@p3_response = stub(
|
93
|
-
body: page_3.to_json,
|
94
|
-
status: 200,
|
95
|
-
headers: {
|
96
|
-
link: '<http://www.example.com/3>; rel="self", <http://www.example.com/1>; rel="previous"'
|
97
|
-
}
|
98
|
-
)
|
99
|
-
|
100
|
-
@client = stub
|
101
|
-
@client.stubs(:get_list).with("http://www.example.com/1").returns(GdsApi::ListResponse.new(@p1_response, @client))
|
102
|
-
@client.stubs(:get_list).with("http://www.example.com/2").returns(GdsApi::ListResponse.new(@p2_response, @client))
|
103
|
-
@client.stubs(:get_list).with("http://www.example.com/3").returns(GdsApi::ListResponse.new(@p3_response, @client))
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "accessing next page" do
|
107
|
-
it "should allow accessing the next page" do
|
108
|
-
resp = GdsApi::ListResponse.new(@p1_response, @client)
|
109
|
-
assert resp.has_next_page?
|
110
|
-
assert_equal %w(foo2 bar2), resp.next_page['results']
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should return nil with no next page" do
|
114
|
-
resp = GdsApi::ListResponse.new(@p3_response, @client)
|
115
|
-
assert ! resp.has_next_page?
|
116
|
-
assert_equal nil, resp.next_page
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should memoize the next_page" do
|
120
|
-
resp = GdsApi::ListResponse.new(@p1_response, @client)
|
121
|
-
first_call = resp.next_page
|
122
|
-
|
123
|
-
@client.unstub(:get_list) # Necessary because of https://github.com/freerange/mocha/issues/44
|
124
|
-
@client.expects(:get_list).never
|
125
|
-
second_call = resp.next_page
|
126
|
-
assert_equal first_call, second_call
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "accessing previous page" do
|
131
|
-
it "should allow accessing the previous page" do
|
132
|
-
resp = GdsApi::ListResponse.new(@p2_response, @client)
|
133
|
-
assert resp.has_previous_page?
|
134
|
-
assert_equal %w(foo1 bar1), resp.previous_page['results']
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should return nil with no previous page" do
|
138
|
-
resp = GdsApi::ListResponse.new(@p1_response, @client)
|
139
|
-
assert ! resp.has_previous_page?
|
140
|
-
assert_equal nil, resp.previous_page
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should memoize the previous_page" do
|
144
|
-
resp = GdsApi::ListResponse.new(@p3_response, @client)
|
145
|
-
first_call = resp.previous_page
|
146
|
-
|
147
|
-
@client.unstub(:get_list) # Necessary because of https://github.com/freerange/mocha/issues/44
|
148
|
-
@client.expects(:get_list).never
|
149
|
-
second_call = resp.previous_page
|
150
|
-
assert_equal first_call, second_call
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "accessing content across all pages" do
|
155
|
-
before :each do
|
156
|
-
@response = GdsApi::ListResponse.new(@p1_response, @client)
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should allow iteration across multiple pages" do
|
160
|
-
assert_equal 6, @response.with_subsequent_pages.count
|
161
|
-
assert_equal %w(foo1 bar1 foo2 bar2 foo3 bar3), @response.with_subsequent_pages.to_a
|
162
|
-
assert_equal %w(foo1 foo2 foo3), @response.with_subsequent_pages.select { |s| s =~ /foo/ }
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should not load a page multiple times" do
|
166
|
-
@client.unstub(:get_list) # Necessary because of https://github.com/freerange/mocha/issues/44
|
167
|
-
@client.expects(:get_list).with("http://www.example.com/2").once.returns(GdsApi::ListResponse.new(@p2_response, @client))
|
168
|
-
@client.expects(:get_list).with("http://www.example.com/3").once.returns(GdsApi::ListResponse.new(@p3_response, @client))
|
169
|
-
|
170
|
-
3.times do
|
171
|
-
@response.with_subsequent_pages.to_a
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should work with a non-paginated response" do
|
176
|
-
data = {
|
177
|
-
"results" => %w(foo1 bar1),
|
178
|
-
"total" => 2,
|
179
|
-
"_response_info" => {
|
180
|
-
"status" => "ok",
|
181
|
-
}
|
182
|
-
}
|
183
|
-
response = GdsApi::ListResponse.new(stub(body: data.to_json, status: 200, headers: {}), nil)
|
184
|
-
|
185
|
-
assert_equal %w(foo1 bar1), response.with_subsequent_pages.to_a
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
@@ -1,236 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "gds_api/local_links_manager"
|
3
|
-
require "gds_api/test_helpers/local_links_manager"
|
4
|
-
|
5
|
-
describe GdsApi::LocalLinksManager do
|
6
|
-
include GdsApi::TestHelpers::LocalLinksManager
|
7
|
-
|
8
|
-
before do
|
9
|
-
@base_api_url = Plek.current.find("local-links-manager")
|
10
|
-
@api = GdsApi::LocalLinksManager.new(@base_api_url)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#link" do
|
14
|
-
describe "when making request for specific LGIL" do
|
15
|
-
it "returns the local authority and local interaction details if link present" do
|
16
|
-
local_links_manager_has_a_link(
|
17
|
-
authority_slug: "blackburn",
|
18
|
-
lgsl: 2,
|
19
|
-
lgil: 4,
|
20
|
-
url: "http://blackburn.example.com/abandoned-shopping-trolleys/report"
|
21
|
-
)
|
22
|
-
|
23
|
-
expected_response = {
|
24
|
-
"local_authority" => {
|
25
|
-
"name" => "Blackburn",
|
26
|
-
"snac" => "00AG",
|
27
|
-
"tier" => "unitary",
|
28
|
-
"homepage_url" => "http://blackburn.example.com",
|
29
|
-
},
|
30
|
-
"local_interaction" => {
|
31
|
-
"lgsl_code" => 2,
|
32
|
-
"lgil_code" => 4,
|
33
|
-
"url" => "http://blackburn.example.com/abandoned-shopping-trolleys/report",
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
response = @api.local_link("blackburn", 2, 4)
|
38
|
-
assert_equal expected_response, response.to_hash
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns the local authority details only if no link present" do
|
42
|
-
local_links_manager_has_no_link(
|
43
|
-
authority_slug: "blackburn",
|
44
|
-
lgsl: 2,
|
45
|
-
lgil: 4,
|
46
|
-
)
|
47
|
-
|
48
|
-
expected_response = {
|
49
|
-
"local_authority" => {
|
50
|
-
"name" => "Blackburn",
|
51
|
-
"snac" => "00AG",
|
52
|
-
"tier" => "unitary",
|
53
|
-
"homepage_url" => "http://blackburn.example.com",
|
54
|
-
},
|
55
|
-
}
|
56
|
-
|
57
|
-
response = @api.local_link("blackburn", 2, 4)
|
58
|
-
assert_equal expected_response, response.to_hash
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'returns the local authority without a homepage url if no homepage link present' do
|
62
|
-
local_links_manager_has_no_link_and_no_homepage_url(
|
63
|
-
authority_slug: "blackburn",
|
64
|
-
lgsl: 2,
|
65
|
-
lgil: 4,
|
66
|
-
)
|
67
|
-
|
68
|
-
expected_response = {
|
69
|
-
"local_authority" => {
|
70
|
-
"name" => "Blackburn",
|
71
|
-
"snac" => "00AG",
|
72
|
-
"tier" => "unitary",
|
73
|
-
"homepage_url" => nil,
|
74
|
-
},
|
75
|
-
}
|
76
|
-
|
77
|
-
response = @api.local_link("blackburn", 2, 4)
|
78
|
-
assert_equal expected_response, response.to_hash
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe "when making request without LGIL" do
|
83
|
-
it "returns the local authority and local interaction details if link present" do
|
84
|
-
local_links_manager_has_a_fallback_link(
|
85
|
-
authority_slug: "blackburn",
|
86
|
-
lgsl: 2,
|
87
|
-
lgil: 3,
|
88
|
-
url: "http://blackburn.example.com/abandoned-shopping-trolleys/report"
|
89
|
-
)
|
90
|
-
|
91
|
-
expected_response = {
|
92
|
-
"local_authority" => {
|
93
|
-
"name" => "Blackburn",
|
94
|
-
"snac" => "00AG",
|
95
|
-
"tier" => "unitary",
|
96
|
-
"homepage_url" => "http://blackburn.example.com",
|
97
|
-
},
|
98
|
-
"local_interaction" => {
|
99
|
-
"lgsl_code" => 2,
|
100
|
-
"lgil_code" => 3,
|
101
|
-
"url" => "http://blackburn.example.com/abandoned-shopping-trolleys/report",
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
response = @api.local_link("blackburn", 2)
|
106
|
-
assert_equal expected_response, response.to_hash
|
107
|
-
end
|
108
|
-
|
109
|
-
it "returns the local authority and local interaction details if no link present" do
|
110
|
-
local_links_manager_has_no_fallback_link(
|
111
|
-
authority_slug: "blackburn",
|
112
|
-
lgsl: 2
|
113
|
-
)
|
114
|
-
|
115
|
-
expected_response = {
|
116
|
-
"local_authority" => {
|
117
|
-
"name" => "Blackburn",
|
118
|
-
"snac" => "00AG",
|
119
|
-
"tier" => "unitary",
|
120
|
-
"homepage_url" => "http://blackburn.example.com",
|
121
|
-
},
|
122
|
-
}
|
123
|
-
|
124
|
-
response = @api.local_link("blackburn", 2)
|
125
|
-
assert_equal expected_response, response.to_hash
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "when making request with missing required parameters" do
|
130
|
-
it "raises HTTPClientError when authority_slug is missing" do
|
131
|
-
local_links_manager_request_with_missing_parameters(nil, 2)
|
132
|
-
|
133
|
-
assert_raises GdsApi::HTTPClientError do
|
134
|
-
@api.local_link(nil, 2)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
it "raises HTTPClientError when LGSL is missing" do
|
139
|
-
local_links_manager_request_with_missing_parameters('blackburn', nil)
|
140
|
-
|
141
|
-
assert_raises GdsApi::HTTPClientError do
|
142
|
-
@api.local_link('blackburn', nil)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "when making request with invalid required parameters" do
|
148
|
-
it "raises when authority_slug is invalid" do
|
149
|
-
local_links_manager_does_not_have_required_objects("hogwarts", 2)
|
150
|
-
|
151
|
-
assert_raises(GdsApi::HTTPNotFound) do
|
152
|
-
@api.local_link("hogwarts", 2)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
it "raises when LGSL is invalid" do
|
157
|
-
local_links_manager_does_not_have_required_objects("blackburn", 999)
|
158
|
-
|
159
|
-
assert_raises(GdsApi::HTTPNotFound) do
|
160
|
-
@api.local_link("blackburn", 999)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
it "raises when the LGSL and LGIL combination is invalid" do
|
165
|
-
local_links_manager_does_not_have_required_objects("blackburn", 2, 9)
|
166
|
-
|
167
|
-
assert_raises(GdsApi::HTTPNotFound) do
|
168
|
-
@api.local_link("blackburn", 2, 9)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
describe '#local_authority' do
|
175
|
-
describe 'when making a request for a local authority with a parent' do
|
176
|
-
it 'should return the local authority and its parent' do
|
177
|
-
local_links_manager_has_a_district_and_county_local_authority('blackburn', 'rochester')
|
178
|
-
|
179
|
-
expected_response = {
|
180
|
-
"local_authorities" => [
|
181
|
-
{
|
182
|
-
"name" => 'Blackburn',
|
183
|
-
"homepage_url" => "http://blackburn.example.com",
|
184
|
-
"tier" => "district"
|
185
|
-
},
|
186
|
-
{
|
187
|
-
"name" => 'Rochester',
|
188
|
-
"homepage_url" => "http://rochester.example.com",
|
189
|
-
"tier" => "county"
|
190
|
-
}
|
191
|
-
]
|
192
|
-
}
|
193
|
-
|
194
|
-
response = @api.local_authority('blackburn')
|
195
|
-
assert_equal expected_response, response.to_hash
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
describe 'when making a request for a local authority without a parent' do
|
200
|
-
it 'should return the local authority' do
|
201
|
-
local_links_manager_has_a_local_authority('blackburn')
|
202
|
-
|
203
|
-
expected_response = {
|
204
|
-
"local_authorities" => [
|
205
|
-
{
|
206
|
-
"name" => 'Blackburn',
|
207
|
-
"homepage_url" => "http://blackburn.example.com",
|
208
|
-
"tier" => "unitary"
|
209
|
-
}
|
210
|
-
]
|
211
|
-
}
|
212
|
-
|
213
|
-
response = @api.local_authority('blackburn')
|
214
|
-
assert_equal expected_response, response.to_hash
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe 'when making a request without the required parameters' do
|
219
|
-
it "raises HTTPClientError when authority_slug is missing" do
|
220
|
-
local_links_manager_request_without_local_authority_slug
|
221
|
-
|
222
|
-
assert_raises GdsApi::HTTPClientError do
|
223
|
-
@api.local_authority(nil)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
describe 'when making a request with invalid required parameters' do
|
229
|
-
it "raises when authority_slug is invalid" do
|
230
|
-
local_links_manager_does_not_have_an_authority("hogwarts")
|
231
|
-
|
232
|
-
assert_raises(GdsApi::HTTPNotFound) { @api.local_authority("hogwarts") }
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|