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



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



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



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>



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



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>



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



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



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



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