Skip to content

Commit

Permalink
Rename Imminence to PlacesManager
Browse files Browse the repository at this point in the history
  • Loading branch information
georges1996 committed May 1, 2024
1 parent be46853 commit 386fd8a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -98,9 +98,9 @@ jobs:
with:
pact_artifact: pacts

imminence_pact:
places_manager_pact:
needs: generate_pacts
uses: alphagov/imminence/.github/workflows/pact-verify.yml@main
uses: alphagov/places-manager/.github/workflows/pact-verify.yml@main
with:
pact_artifact: pacts

Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
- collections_pact
- email_alert_api_pact
- frontend_pact
- imminence_pact
- places_manager_pact
- link_checker_api_pact
- locations_api_pact
- publishing_api_pact
Expand Down
10 changes: 5 additions & 5 deletions lib/gds_api.rb
Expand Up @@ -6,7 +6,7 @@
require "gds_api/calendars"
require "gds_api/content_store"
require "gds_api/email_alert_api"
require "gds_api/imminence"
require "gds_api/places_manager"
require "gds_api/licence_application"
require "gds_api/link_checker_api"
require "gds_api/local_links_manager"
Expand Down Expand Up @@ -82,11 +82,11 @@ def self.email_alert_api(options = {})
)
end

# Creates a GdsApi::Imminence adapter
# Creates a GdsApi::places-manager adapter
#
# @return [GdsApi::Imminence]
def self.imminence(options = {})
GdsApi::Imminence.new(Plek.find("imminence"), options)
# @return [GdsApi::PlacesManager]
def self.places_manager(options = {})
GdsApi::PlacesManager.new(Plek.find("places-manager"), options)
end

# Creates a GdsApi::LicenceApplication
Expand Down
2 changes: 1 addition & 1 deletion lib/gds_api/imminence.rb → lib/gds_api/places_manager.rb
@@ -1,6 +1,6 @@
require_relative "base"

class GdsApi::Imminence < GdsApi::Base
class GdsApi::PlacesManager < GdsApi::Base
def api_url(type, params)
vals = %i[limit lat lng postcode local_authority_slug].select { |p| params.include? p }
querystring = URI.encode_www_form(vals.map { |p| [p, params[p]] })
Expand Down
Expand Up @@ -2,44 +2,44 @@

module GdsApi
module TestHelpers
module Imminence
module PlacesManager
# Generally true. If you are initializing the client differently,
# you could redefine/override the constant or stub directly.
IMMINENCE_API_ENDPOINT = Plek.find("imminence")
PLACES_MANAGER_API_ENDPOINT = Plek.find("places-manager")

def stub_imminence_has_places(latitude, longitude, details)
def stub_places_manager_has_places(latitude, longitude, details)
query_hash = { "lat" => latitude, "lng" => longitude, "limit" => "5" }
response_data = {
status: "ok",
content: "places",
places: details["details"],
}
stub_imminence_places_request(details["slug"], query_hash, response_data)
stub_places_manager_places_request(details["slug"], query_hash, response_data)
end

def stub_imminence_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit)
def stub_places_manager_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit)
query_hash = { "postcode" => postcode, "limit" => limit }
response_data = {
status: "address-information-required",
content: "addresses",
addresses:,
}
stub_imminence_places_request(slug, query_hash, response_data)
stub_places_manager_places_request(slug, query_hash, response_data)
end

def stub_imminence_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug)
def stub_places_manager_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug)
query_hash = { "postcode" => postcode, "limit" => limit }
query_hash.merge!(local_authority_slug:) if local_authority_slug
response_data = {
status: "ok",
content: "places",
places:,
}
stub_imminence_places_request(slug, query_hash, response_data)
stub_places_manager_places_request(slug, query_hash, response_data)
end

def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{slug}.json")
def stub_places_manager_places_request(slug, query_hash, return_data, status_code = 200)
stub_request(:get, "#{PLACES_MANAGER_API_ENDPOINT}/places/#{slug}.json")
.with(query: query_hash)
.to_return(status: status_code, body: return_data.to_json, headers: {})
end
Expand Down
@@ -1,14 +1,14 @@
require "test_helper"
require "gds_api/imminence"
require "gds_api/places_manager"

describe "GdsApi::Imminence pact tests" do
describe "GdsApi::PlacesManager pact tests" do
include PactTest

describe "#places" do
let(:api_client) { GdsApi::Imminence.new(imminence_api_host) }
let(:api_client) { GdsApi::PlacesManager.new(places_manager_api_host) }

it "responds with all responses for the given dataset" do
imminence_api
places_manager_api
.given("a service exists called number-plate-supplier with places")
.upon_receiving("the request to retrieve relevant places for the current dataset for a lat/lon")
.with(
Expand Down Expand Up @@ -56,7 +56,7 @@
end

it "responds with a choice of addresses for disambiguation of split postcodes" do
imminence_api
places_manager_api
.given("a service exists called register office exists with places, and CH25 9BJ is a split postcode")
.upon_receiving("the request to retrieve relevant places for the current dataset for CH25 9BJ")
.with(
Expand Down
@@ -1,13 +1,13 @@
require "test_helper"
require "gds_api/imminence"
require "gds_api/places_manager"

class ImminenceApiTest < Minitest::Test
ROOT = Plek.find("imminence")
class PlacesManagerApiTest < Minitest::Test
ROOT = Plek.find("places-manager")
LATITUDE = 52.1327584352089
LONGITUDE = -0.4702813074674147

def api_client
GdsApi::Imminence.new(ROOT)
GdsApi::PlacesManager.new(ROOT)
end

def dummy_place
Expand Down
12 changes: 6 additions & 6 deletions test/support/pact_helper.rb
Expand Up @@ -5,7 +5,7 @@
BANK_HOLIDAYS_API_PORT = 3003
ACCOUNT_API_PORT = 3004
LINK_CHECKER_API_PORT = 3005
IMMINENCE_API_PORT = 3006
PLACES_MANAGER_API_PORT = 3006
LOCATIONS_API_PORT = 3008
ASSET_MANAGER_API_PORT = 3009
EMAIL_ALERT_API_PORT = 3010
Expand All @@ -30,8 +30,8 @@ def link_checker_api_host
"http://localhost:#{LINK_CHECKER_API_PORT}"
end

def imminence_api_host
"http://localhost:#{IMMINENCE_API_PORT}"
def places_manager_api_host
"http://localhost:#{PLACES_MANAGER_API_PORT}"
end

def locations_api_host
Expand Down Expand Up @@ -77,9 +77,9 @@ def email_alert_api_host
end
end

has_pact_with "Imminence API" do
mock_service :imminence_api do
port IMMINENCE_API_PORT
has_pact_with "PlacesManager API" do
mock_service :places_manager_api do
port PLACES_MANAGER_API_PORT
end
end

Expand Down

0 comments on commit 386fd8a

Please sign in to comment.