gds-api-adapters 26.3.1 → 26.4.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0855c236df08760a5bb3c690fe3edea108d3448
|
4
|
+
data.tar.gz: c5c1ef0acb097c7a29899a8051ba2f7c5f3fab30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da29b92b57fb706bfc91914383e6720d6d72002a7eea5bb1b10bbbbfe845a26e91cef7a03aabce3b26b6912e5f816cb98c6435297d24575de3d734b3d47370e8
|
7
|
+
data.tar.gz: 6aa6907363f65a729e003747033ced7faf5a8c294b1abd9832b273d8f44b8c9852aed0d19d3366bd0fd61da17aab4faeaf4b0e048d8f391e83f53a16f84e6e70
|
@@ -13,6 +13,12 @@ class GdsApi::ContentStore < GdsApi::Base
|
|
13
13
|
get_json(content_item_url(base_path))
|
14
14
|
end
|
15
15
|
|
16
|
+
def incoming_links!(base_path)
|
17
|
+
get_json!(incoming_links_url(base_path))
|
18
|
+
rescue GdsApi::HTTPNotFound => e
|
19
|
+
raise ItemNotFound.build_from(e)
|
20
|
+
end
|
21
|
+
|
16
22
|
def content_item!(base_path)
|
17
23
|
get_json!(content_item_url(base_path))
|
18
24
|
rescue GdsApi::HTTPNotFound => e
|
@@ -24,4 +30,8 @@ class GdsApi::ContentStore < GdsApi::Base
|
|
24
30
|
def content_item_url(base_path)
|
25
31
|
"#{endpoint}/content#{base_path}"
|
26
32
|
end
|
33
|
+
|
34
|
+
def incoming_links_url(base_path)
|
35
|
+
"#{endpoint}/incoming-links#{base_path}"
|
36
|
+
end
|
27
37
|
end
|
@@ -34,6 +34,9 @@ module GdsApi
|
|
34
34
|
def content_store_does_not_have_item(base_path)
|
35
35
|
url = CONTENT_STORE_ENDPOINT + "/content" + base_path
|
36
36
|
stub_request(:get, url).to_return(status: 404, headers: {})
|
37
|
+
|
38
|
+
url = CONTENT_STORE_ENDPOINT + "/incoming-links" + base_path
|
39
|
+
stub_request(:get, url).to_return(status: 404, headers: {})
|
37
40
|
end
|
38
41
|
|
39
42
|
def content_store_isnt_available
|
@@ -43,6 +46,13 @@ module GdsApi
|
|
43
46
|
def content_item_for_base_path(base_path)
|
44
47
|
super.merge({ "base_path" => base_path })
|
45
48
|
end
|
49
|
+
|
50
|
+
def content_store_has_incoming_links(base_path, links)
|
51
|
+
url = CONTENT_STORE_ENDPOINT + "/incoming-links" + base_path
|
52
|
+
body = links.to_json
|
53
|
+
|
54
|
+
stub_request(:get, url).to_return(body: body)
|
55
|
+
end
|
46
56
|
end
|
47
57
|
end
|
48
58
|
end
|
@@ -35,6 +35,10 @@ module GdsApi
|
|
35
35
|
def stub_pp_isnt_available
|
36
36
|
stub_request(:post, /#{PP_DATA_IN_ENDPOINT}\/.*/).to_return(:status => 503)
|
37
37
|
end
|
38
|
+
|
39
|
+
def stub_pp_dataset_unavailable
|
40
|
+
stub_request(:any, /#{PP_DATA_IN_ENDPOINT}/).to_return(:status => 404)
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_store_test.rb
CHANGED
@@ -10,35 +10,63 @@ describe GdsApi::ContentStore do
|
|
10
10
|
@api = GdsApi::ContentStore.new(@base_api_url)
|
11
11
|
end
|
12
12
|
|
13
|
-
describe "content_item" do
|
14
|
-
it "
|
13
|
+
describe "#content_item" do
|
14
|
+
it "returns the item" do
|
15
15
|
base_path = "/test-from-content-store"
|
16
16
|
content_store_has_item(base_path)
|
17
|
+
|
17
18
|
response = @api.content_item(base_path)
|
19
|
+
|
18
20
|
assert_equal base_path, response["base_path"]
|
19
21
|
end
|
20
22
|
|
21
|
-
it "
|
23
|
+
it "returns nil if the item doesn't exist" do
|
22
24
|
content_store_does_not_have_item("/non-existent")
|
25
|
+
|
23
26
|
assert_nil @api.content_item("/non-existent")
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
|
-
describe "content_item!" do
|
28
|
-
it "
|
30
|
+
describe "#content_item!" do
|
31
|
+
it "returns the item" do
|
29
32
|
base_path = "/test-from-content-store"
|
30
33
|
content_store_has_item(base_path)
|
34
|
+
|
31
35
|
response = @api.content_item!(base_path)
|
36
|
+
|
32
37
|
assert_equal base_path, response["base_path"]
|
33
38
|
end
|
34
39
|
|
35
|
-
it "
|
40
|
+
it "raises if the item doesn't exist" do
|
36
41
|
content_store_does_not_have_item("/non-existent")
|
42
|
+
|
37
43
|
e = assert_raises GdsApi::ContentStore::ItemNotFound do
|
38
44
|
@api.content_item!("/non-existent")
|
39
45
|
end
|
46
|
+
|
40
47
|
assert_equal 404, e.code
|
41
48
|
assert_equal "url: #{@base_api_url}/content/non-existent", e.message.strip
|
42
49
|
end
|
43
50
|
end
|
51
|
+
|
52
|
+
describe "#incoming_links!" do
|
53
|
+
it "returns the item" do
|
54
|
+
base_path = "/test-from-content-store"
|
55
|
+
content_store_has_incoming_links(base_path, [ { title: "Yolo" }])
|
56
|
+
|
57
|
+
response = @api.incoming_links!(base_path)
|
58
|
+
|
59
|
+
assert_equal [ { "title" => "Yolo" } ], response.to_hash
|
60
|
+
end
|
61
|
+
|
62
|
+
it "raises if the item doesn't exist" do
|
63
|
+
content_store_does_not_have_item("/non-existent")
|
64
|
+
|
65
|
+
e = assert_raises GdsApi::ContentStore::ItemNotFound do
|
66
|
+
response = @api.incoming_links!("/non-existent")
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_equal 404, e.code
|
70
|
+
end
|
71
|
+
end
|
44
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 26.
|
4
|
+
version: 26.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|