Class: QaServer::ScenariosLoaderService

Inherits:
Object
  • Object
show all
Defined in:
app/services/qa_server/scenarios_loader_service.rb

Class Method Summary collapse

Class Method Details

.load(authority_name:, status_log:) ⇒ Scenarios

Load scenarios for testing an authority

Parameters:

  • authority_name (String)

    name of the authority to load (e.g. “agrovoc_direct”)

  • status_log (ScenarioLogger)

    logger to hold failure information if the scenarios cannot be loaded

Returns:

  • (Scenarios)

    the instance of the set of scenarios to test for the authority OR nil if fails to load



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/qa_server/scenarios_loader_service.rb', line 9

def self.load(authority_name:, status_log:)
  begin
    authority = load_authority(authority_name, status_log)
    return nil if authority.blank?
    return nil unless scenarios_exist?(authority_name, status_log)

    scenarios_config = load_config(authority_name, status_log)
    return nil if scenarios_config.blank?

    scenarios = QaServer::Scenarios.new(authority: authority, authority_name: authority_name, scenarios_config: scenarios_config)
  rescue Exception => e
    status_log.add(authority_name: authority_name,
                   status: QaServer::ScenarioValidator::FAIL,
                   error_message: "Unable to load scenarios for authority '#{authority_name}'; cause: #{e.message}")
    return nil
  end
  scenarios
end