Skip to content

Commit

Permalink
EDM-346/enable gids flight school mocks (#19649)
Browse files Browse the repository at this point in the history
* Update search client/config to use mocks if program type is flight

* Update betamocks setting

* Update namespace

* Add guard clause to search use mocks

* Linting

* Linting
  • Loading branch information
jefftmarks authored Nov 29, 2024
1 parent 323159a commit 2dfa7f7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/betamocks/services_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,13 @@
- :name: "GIDS"
:base_uri: <%= "#{URI(Settings.gids.url).host}:#{URI(Settings.gids.url).port}" %>
:endpoints:
- :method: :get
:path: "/gids/v0/institution_programs"
:file_path: "gids/programs"
# Mock only enabled when filtering by flight programs, see: lib/gi/search_client.rb
:cache_multiple_responses:
:uid_location: query
:uid_locator: type
- :method: :get
:path: "/gids/v1/lce"
:file_path: "gids/lce"
Expand Down
2 changes: 2 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ gids:
url: https://dev.va.gov/gids
open_timeout: 1
read_timeout: 1
search:
use_mocks: false
lce:
use_mocks: false

Expand Down
4 changes: 4 additions & 0 deletions lib/gi/search_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def get_institution_search_results_v0(params = {})
end

def get_institution_program_search_results_v0(params = {})
# Mock response if querying for flight school programs
# TO-DO: Remove after flight school program data becomes accessible
config.instance_variable_set(:@program_type_flight, true) if params[:type] == 'FLGT'

response = perform(:get, 'v0/institution_programs', params)
gids_response(response)
end
Expand Down
9 changes: 9 additions & 0 deletions lib/gi/search_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@ module GI
class SearchConfiguration < GI::Configuration
self.read_timeout = Settings.gids.search&.read_timeout || 4
self.open_timeout = Settings.gids.search&.open_timeout || 4

# Mock response if querying for flight school programs
# TO-DO: Remove after flight school program data becomes accessible
def use_mocks?
return false unless instance_variable_defined?(:@program_type_flight)

querying_by_flight = remove_instance_variable(:@program_type_flight)
(querying_by_flight && Settings.gids.search.use_mocks) || false
end
end
end

0 comments on commit 2dfa7f7

Please sign in to comment.