-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EDM-213/build lce interface and mockdata (#19178)
* Create lce client and config * Create lce client methods * Create lce controllers * Update gids redis to respond to lce client * Create routes * Enable mocks * Add gids response to lce client * Fix linting * Update gids redis spec * LCE client spec * Condense spec file * Update codeowners * Fix linting * Fix typo in spec test * Fix spec typo * Fix spec typo * Fix spec * Revert codeowners * Update services config and settings
- Loading branch information
1 parent
dedb94b
commit cf664de
Showing
14 changed files
with
256 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module GIDS | ||
module Lce | ||
class CertificationsController < LceController | ||
def show | ||
render json: service.get_certification_details_v1(scrubbed_params) | ||
end | ||
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module GIDS | ||
module Lce | ||
class ExamsController < GIDS::LceController | ||
def show | ||
render json: service.get_exam_details_v1(scrubbed_params) | ||
end | ||
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module GIDS | ||
module Lce | ||
class LicensesController < LceController | ||
def show | ||
render json: service.get_license_details_v1(scrubbed_params) | ||
end | ||
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module GIDS | ||
module Lce | ||
class PrepsController < LceController | ||
def show | ||
render json: service.get_prep_details_v1(scrubbed_params) | ||
end | ||
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
module GIDS | ||
class LceController < GIDSController | ||
def index | ||
render json: service.get_lce_search_results_v1(scrubbed_params) | ||
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
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
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
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,41 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'gi/client' | ||
require_relative 'configuration' | ||
|
||
module GI | ||
module Lce | ||
class Client < GI::Client | ||
configuration GI::Lce::Configuration | ||
|
||
def get_lce_search_results_v1(params = {}) | ||
response = perform(:get, 'v1/lce', params) | ||
gids_response(response) | ||
end | ||
|
||
def get_certification_details_v1(params = {}) | ||
certification_id = params[:id] | ||
response = perform(:get, "v1/lce/certifications/#{certification_id}", params.except(:id)) | ||
gids_response(response) | ||
end | ||
|
||
def get_exam_details_v1(params = {}) | ||
exam_id = params[:id] | ||
response = perform(:get, "v1/lce/exams/#{exam_id}", params.except(:id)) | ||
gids_response(response) | ||
end | ||
|
||
def get_license_details_v1(params = {}) | ||
license_id = params[:id] | ||
response = perform(:get, "v1/lce/licenses/#{license_id}", params.except(:id)) | ||
gids_response(response) | ||
end | ||
|
||
def get_prep_details_v1(params = {}) | ||
prep_id = params[:id] | ||
response = perform(:get, "v1/lce/preps/#{prep_id}", params.except(:id)) | ||
gids_response(response) | ||
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'gi/configuration' | ||
|
||
module GI | ||
module Lce | ||
class Configuration < GI::Configuration | ||
def use_mocks? | ||
Settings.gids.lce.use_mocks || false | ||
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,64 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'gi/lce/client' | ||
require 'gi/gids_response' | ||
|
||
# TO-DO: Replace stubbed data with VCR cassettes after GIDS connection established | ||
describe GI::Lce::Client do | ||
let(:client) { GI::Lce::Client.new } | ||
let(:search_data) do | ||
[ | ||
{ | ||
link: 'lce/certifications/1', | ||
name: 'Certification Name', | ||
type: 'certification' | ||
} | ||
] | ||
end | ||
let(:institution) { { name: 'Institution' } } | ||
let(:lcp_data) do | ||
{ | ||
desc: 'License Name', | ||
type: 'license', | ||
tests: [{ name: 'Test Name' }], | ||
institution: institution, | ||
officials: [{ title: 'Certifying Official' }] | ||
} | ||
end | ||
let(:exam_data) do | ||
{ | ||
name: 'Exam Name', | ||
tests: [{ description: 'Description' }], | ||
institution: institution | ||
} | ||
end | ||
|
||
it 'gets a list of licenses, certifications, exams, and prep courses' do | ||
search_response = OpenStruct.new(body: { data: search_data }) | ||
allow(client).to receive(:get_lce_search_results_v1).with(type: 'all').and_return(search_response) | ||
client_response = client.get_lce_search_results_v1(type: 'all').body | ||
expect(client_response[:data]).to be_an(Array) | ||
end | ||
|
||
%w[license certification prep].each do |type| | ||
it "gets #{type} details" do | ||
details_response = OpenStruct.new(body: { data: lcp_data }) | ||
query_method = :"get_#{type}_details_v1" | ||
|
||
allow(client).to receive(query_method).with(id: '1').and_return(details_response) | ||
client_response = client.send(query_method, id: '1').body | ||
expect(client_response[:data]).to be_an(Hash) | ||
expect(client_response[:data].keys).to contain_exactly(:desc, :type, :tests, :institution, :officials) | ||
end | ||
end | ||
|
||
it 'gets exam details' do | ||
details_response = OpenStruct.new(body: { data: exam_data }) | ||
|
||
allow(client).to receive(:get_exam_details_v1).with(id: '1').and_return(details_response) | ||
client_response = client.get_exam_details_v1(id: '1').body | ||
expect(client_response[:data]).to be_an(Hash) | ||
expect(client_response[:data].keys).to contain_exactly(:name, :tests, :institution) | ||
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