Class: Inferno::Entities::TestSession

Inherits:
Entity
  • Object
show all
Includes:
Attributes
Defined in:
lib/inferno/entities/test_session.rb

Overview

A ‘TestSession` represents an individual testing session.

Constant Summary collapse

ATTRIBUTES =
[
  :id,
  :created_at,
  :updated_at,
  :test_suite_id,
  :test_suite,
  :test_runs,
  :results,
  :suite_options
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Attributes

included

Constructor Details

#initialize(params) ⇒ TestSession

Returns a new instance of TestSession.



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/inferno/entities/test_session.rb', line 38

def initialize(params)
  super(params, ATTRIBUTES)

  self.suite_options ||= []

  test_suite&.suite_options&.each do |option|
    if suite_options.none? { |selected_option| selected_option.id == option.id }
      suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
    end
  end
end

Instance Attribute Details

#created_atTime

Returns creation timestamp.

Returns:

  • (Time)

    creation timestamp



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

#idString

Returns id of the session.

Returns:

  • (String)

    id of the session



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

#resultsArray<Inferno::Entities::TestResult>

associated with this session

Returns:

  • (Array<Inferno::Entities::TestResult>)

    the ‘TestResults`



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

#suite_optionsHash

Returns the suite options associated with this session.

Returns:

  • (Hash)

    the suite options associated with this session



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

#test_runsArray<Inferno::Entities::TestRun>

with this session

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

#test_suiteInferno::Entities::TestSuite

session

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

#test_suite_idString

Returns id of the ‘TestSuite` being run in this session.

Returns:

  • (String)

    id of the ‘TestSuite` being run in this session



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

#updated_atTime

Returns update timestamp.

Returns:

  • (Time)

    update timestamp



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inferno/entities/test_session.rb', line 24

class TestSession < Entity
  ATTRIBUTES = [
    :id,
    :created_at,
    :updated_at,
    :test_suite_id,
    :test_suite,
    :test_runs,
    :results,
    :suite_options
  ].freeze

  include Inferno::Entities::Attributes

  def initialize(params)
    super(params, ATTRIBUTES)

    self.suite_options ||= []

    test_suite&.suite_options&.each do |option|
      if suite_options.none? { |selected_option| selected_option.id == option.id }
        suite_options << DSL::SuiteOption.new(id: option.id, value: option.list_options.first[:value])
      end
    end
  end

  def test_suite
    @test_suite ||= Repositories::TestSuites.new.find(test_suite_id)
  end

  def to_hash
    session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
      hash[attribute] = send(attribute)
    end

    session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

    session_hash.compact
  end

  def suite_options_hash
    (suite_options || []).each_with_object({}) do |option, hash|
      hash[option.id] = option.value
    end
  end
end

Instance Method Details

#suite_options_hashObject



64
65
66
67
68
# File 'lib/inferno/entities/test_session.rb', line 64

def suite_options_hash
  (suite_options || []).each_with_object({}) do |option, hash|
    hash[option.id] = option.value
  end
end

#to_hashObject



54
55
56
57
58
59
60
61
62
# File 'lib/inferno/entities/test_session.rb', line 54

def to_hash
  session_hash = (self.class::ATTRIBUTES - [:suite_options]).each_with_object({}) do |attribute, hash|
    hash[attribute] = send(attribute)
  end

  session_hash[:suite_options] = suite_options&.map(&:to_hash) || []

  session_hash.compact
end