Class: Testplan

Inherits:
Object
  • Object
show all
Defined in:
lib/testplan.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(testplan = nil) ⇒ Testplan

Returns a new instance of Testplan.



35
36
37
38
# File 'lib/testplan.rb', line 35

def initialize(testplan=nil)
  @testplan = testplan
  @check = true
end

Instance Attribute Details

#checkObject

Returns the value of attribute check.



40
41
42
# File 'lib/testplan.rb', line 40

def check
  @check
end

#testplanObject

Returns the value of attribute testplan.



40
41
42
# File 'lib/testplan.rb', line 40

def testplan
  @testplan
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


98
99
100
101
102
103
104
105
# File 'lib/testplan.rb', line 98

def exists?
  @result = self.find 
  if @result.empty?
    return false
  else
    return true
  end
end

#findObject



91
92
93
94
95
# File 'lib/testplan.rb', line 91

def find
  @query = {"name"=>@testplan["name"], "product_id"=>@testplan["product"]}
  @result = $server.call("TestPlan.list", @query)
  return @result
end

#get_product_id(plan_id) ⇒ Object



108
109
110
111
# File 'lib/testplan.rb', line 108

def get_product_id(plan_id)
  @product = $server.call("TestPlan.get_product", plan_id)
  return @product["id"]
end


86
87
88
# File 'lib/testplan.rb', line 86

def print
  puts @testplan.inspect
end

#read(id) ⇒ Object



80
81
82
83
# File 'lib/testplan.rb', line 80

def read(id)
  @testplan = $server.call("TestPlan.get", id)
  return @testplan
end

#writeObject



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
70
71
72
73
74
75
76
77
# File 'lib/testplan.rb', line 44

def write 
  if @testplan["product"].nil?
    puts "No product ID set while attempting to create Testplan"
    return false
  elsif @testplan["name"].nil?
    puts "No name is set while attempting to create a testplan"
    return false
  elsif @testplan["default_product_version"].nil?
    puts "No product_version is set while attempting to create a testplan"
    return false
  end

  if @testplan["isactive"].nil?
    puts "Activity state of testplan not set while creating testplan. Using [isactive = 1]"
    @testplan["isactive"] = 1
  end 
  if @testplan["type"].nil?
    puts "Testplan type not set while creating Testplan. Using [Function]"
    @testplan["type"] = "Function"
  end

  if @check
    if self.exists?
      puts "Testplan already existing - aborting"
      return false
    else
      @testplan = $server.call("TestPlan.create", @testplan)
      return @testplan
    end
  else
    @testplan = $server.call("TestPlan.create", @testplan)
    return @testplan    
  end
end