Class: QaServer::SearchScenario

Inherits:
AuthorityScenario show all
Defined in:
app/models/qa_server/search_scenario.rb

Constant Summary collapse

MAX_RECORDS =
'4'
DEFAULT_REPLACEMENTS =
{ maxRecords: MAX_RECORDS }.freeze
DEFAULT_POSITION =
nil
DEFAULT_SUBJECT_URI =
nil

Constants inherited from AuthorityScenario

AuthorityScenario::DEFAULT_SUBAUTH, AuthorityScenario::MIN_EXPECTED_SIZE

Instance Attribute Summary collapse

Attributes inherited from AuthorityScenario

#authority, #authority_name, #min_result_size, #service, #subauthority_name

Instance Method Summary collapse

Methods inherited from AuthorityScenario

#context?

Constructor Details

#initialize(authority:, authority_name:, authority_scenario_config:, scenario_config:) ⇒ SearchScenario

Returns a new instance of SearchScenario.

Parameters:

  • authority (Qa::Authorities::LinkedData::GenericAuthority)

    the instance of the QA authority

  • authority_name (Symbol)

    the name of the authority the scenario tests (e.g. :AGROVOC_DIRECT)

  • authority_scenario_config (Hash)

    configurations from the yml file that pertain to all scenarios regardless of type

  • scenario_config (Hash)

    configuration from the yml file that are specific to a search scenario



26
27
28
29
30
31
32
33
34
35
# File 'app/models/qa_server/search_scenario.rb', line 26

def initialize(authority:, authority_name:, authority_scenario_config:, scenario_config:) # rubocop:disable Metrics/CyclomaticComplexity
  super
  @query = scenario_config['query']
  @subauthority_name = scenario_config['subauth'] || DEFAULT_SUBAUTH
  @min_result_size = scenario_config['result_size'] || MIN_EXPECTED_SIZE
  @replacements = scenario_config['replacements'] || DEFAULT_REPLACEMENTS
  @expected_by_position = scenario_config['position'] || DEFAULT_POSITION
  @subject_uri = scenario_config['subject_uri'] || DEFAULT_SUBJECT_URI
  @pending = scenario_config['pending'] || false
end

Instance Attribute Details

#expected_by_positionInteger (readonly)

Returns expected_by_position designates the maximum position in search results of subject_uri, if specified, for this scenario to be considered passing.

Returns:

  • (Integer)

    expected_by_position designates the maximum position in search results of subject_uri, if specified, for this scenario to be considered passing



12
13
14
# File 'app/models/qa_server/search_scenario.rb', line 12

def expected_by_position
  @expected_by_position
end

#queryString (readonly)

Returns query being executed by this scenario.

Returns:

  • (String)

    query being executed by this scenario



6
7
8
# File 'app/models/qa_server/search_scenario.rb', line 6

def query
  @query
end

#replacementsHash (readonly)

Returns replacements parameters used to construct the URL executed by this scenario.

Returns:

  • (Hash)

    replacements parameters used to construct the URL executed by this scenario



9
10
11
# File 'app/models/qa_server/search_scenario.rb', line 9

def replacements
  @replacements
end

#subject_uriString (readonly)

Returns subject_uri, if specified, should be in the search results between position 1 and expected_by_position.

Returns:

  • (String)

    subject_uri, if specified, should be in the search results between position 1 and expected_by_position



15
16
17
# File 'app/models/qa_server/search_scenario.rb', line 15

def subject_uri
  @subject_uri
end

Instance Method Details

#pending?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/qa_server/search_scenario.rb', line 46

def pending?
  @pending
end

#urlString

Generate an example URL that can be called in a browser or through curl

Returns:

  • (String)

    the example URL



39
40
41
42
43
44
# File 'app/models/qa_server/search_scenario.rb', line 39

def url
  subauth = "/#{subauthority_name}" if subauthority?
  context = context? ? '&context=true' : ''
  prefix = "#{QaServer::Engine.qa_engine_mount}/search/linked_data/#{authority_name.downcase}#{subauth}"
  "#{prefix}?q=#{query}#{url_replacements}#{context}"
end