-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for /schemas end points in Publishing API
`/schemas` and `/schemas/{schema_name}` were added to the Publishing API in this PR [1] This adds methods to the publishing_api adapter [1] alphagov/publishing-api#2767
- Loading branch information
Showing
3 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require "test_helper" | ||
require "gds_api/publishing_api" | ||
|
||
describe "GdsApi::PublishingApi#get_schemas pact tests" do | ||
include PactTest | ||
|
||
let(:api_client) { GdsApi::PublishingApi.new(publishing_api_host) } | ||
|
||
let(:schema) do | ||
{ | ||
"email_address": { "some": "schema" }, | ||
} | ||
end | ||
|
||
describe "when a schema is found" do | ||
before do | ||
publishing_api | ||
.given("there is a schema for an email address") | ||
.upon_receiving("a get schema by name request") | ||
.with( | ||
method: :get, | ||
path: "/v2/schemas/email_address", | ||
) | ||
.will_respond_with( | ||
status: 200, | ||
body: schema, | ||
) | ||
end | ||
|
||
it "returns the named schema" do | ||
response = api_client.get_schema("email_address") | ||
assert_equal(schema.to_json, response.to_json) | ||
end | ||
end | ||
|
||
describe "when a schema is not found" do | ||
before do | ||
publishing_api | ||
.given("there is not a schema for a given name") | ||
.upon_receiving("a get schema by name request") | ||
.with( | ||
method: :get, | ||
path: "/v2/schemas/email_address", | ||
) | ||
.will_respond_with( | ||
status: 404, | ||
) | ||
end | ||
|
||
it "returns a 404 error" do | ||
assert_raises(GdsApi::HTTPNotFound) do | ||
api_client.get_schema("email_address") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "test_helper" | ||
require "gds_api/publishing_api" | ||
|
||
describe "GdsApi::PublishingApi##get_schemas_by_name pact tests" do | ||
include PactTest | ||
|
||
let(:api_client) { GdsApi::PublishingApi.new(publishing_api_host) } | ||
|
||
let(:schemas) do | ||
{ | ||
"email_address": { "some": "schema" }, | ||
"tax_licence": { "another": "schema" }, | ||
} | ||
end | ||
|
||
before do | ||
publishing_api | ||
.given("there are schemas") | ||
.upon_receiving("a get schemas request") | ||
.with( | ||
method: :get, | ||
path: "/v2/schemas", | ||
) | ||
.will_respond_with( | ||
status: 200, | ||
body: schemas, | ||
) | ||
end | ||
|
||
it "returns all the schemas" do | ||
response = api_client.get_schemas | ||
assert_equal(schemas.to_json, response.to_json) | ||
end | ||
end |