Class: TestdroidApi::Client::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/testdroid-api/client/project.rb,
lib/testdroid-api/client/project/test_run.rb,
lib/testdroid-api/client/project/test_run/device_run.rb

Defined Under Namespace

Classes: TestRun

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, config) ⇒ Project

Returns a new instance of Project.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/testdroid-api/client/project.rb', line 6

def initialize(client, config)
  @client      = client
  @id          = config['id']
  @name        = config['name']
  @description = config['description']

  #TODO: Add uploadTimeslate
  @app_file    = config['appFile'] && config['appFile']['originalName']

  #TODO: Add uploadTime
  @test_file   = config['testFile'] && config['testFile']['originalName']
end

Instance Attribute Details

#app_fileObject (readonly)

Returns the value of attribute app_file.



5
6
7
# File 'lib/testdroid-api/client/project.rb', line 5

def app_file
  @app_file
end

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/testdroid-api/client/project.rb', line 5

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/testdroid-api/client/project.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/testdroid-api/client/project.rb', line 5

def name
  @name
end

#test_fileObject (readonly)

Returns the value of attribute test_file.



5
6
7
# File 'lib/testdroid-api/client/project.rb', line 5

def test_file
  @test_file
end

Instance Method Details

#configObject

Raises:

  • (NotImplementedError)


89
90
91
# File 'lib/testdroid-api/client/project.rb', line 89

def config
  raise NotImplementedError
end

#create_test_run(device_group = 'all devices', instatest = false, screenshots = false) ⇒ TestdroidApi::Client::Project::TestRun

Start new test run

Parameters:

  • device_group (TestdroidApi::Client::DeviceGroup) (defaults to: 'all devices')

    devices to be tested

  • instatest (Boolean) (defaults to: false)

    run project in instatest mode

  • screenshots (Boolean) (defaults to: false)

    take screenshots automatically

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/testdroid-api/client/project.rb', line 63

def create_test_run(device_group = 'all devices', instatest = false, screenshots = false)
  res_name = "project/run/#{id}"
  endpoint = "projects/#{id}/run"
  params   = {
    :instatestMode   => instatest,
    :autoScreenshots => screenshots,
    :usedClusterId   => get_group_id(device_group)
  }
  test_run = @client.post_api_request(endpoint, params, res_name)

  TestdroidApi::Client::Project::TestRun.new(@client, self, test_run)
end

#delete!Object

Delete project



50
51
52
53
54
55
# File 'lib/testdroid-api/client/project.rb', line 50

def delete!
  res_name = "project/#{id}"
  endpoint = "projects/#{id}/delete"

  @client.post_api_request(endpoint, nil, res_name)
end

#test_runsArray<Project>

Returns project runs from project

Returns:



78
79
80
81
82
83
84
85
86
87
# File 'lib/testdroid-api/client/project.rb', line 78

def test_runs
  res_name = "runs"
  endpoint = "projects/#{id}/runs"

  configs = @client.get_api_request(endpoint, res_name)

  configs.map{|config|
    TestdroidApi::Client::Project::TestRun.new(@client, self, config)
  }
end

#update_config(new_config) ⇒ Object

Raises:

  • (NotImplementedError)


93
94
95
# File 'lib/testdroid-api/client/project.rb', line 93

def update_config(new_config)
  raise NotImplementedError
end

#upload_app_file(path) ⇒ Object

Upload application binary

Parameters:

  • path

    path to application file



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/testdroid-api/client/project.rb', line 21

def upload_app_file(path)
  endpoint = "projects/#{id}/apks/application"

  file     = File.new(path)
  digest   = mh5digest(file)
  params   = { :file => file, :multipart => true }

  res_name = "upload#{id}application#{digest}"
  extra_headers = {'X-Testdroid-MD5' => digest}

  @client.post_api_request(endpoint, params, res_name, extra_headers )
end

#upload_test_file(path) ⇒ Object

Upload test binary

Parameters:

  • path

    path to test file



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/testdroid-api/client/project.rb', line 36

def upload_test_file(path)
  endpoint = "projects/#{id}/apks/instrumentation"

  file     = File.new(path)
  digest   = mh5digest(file)
  params   = { :file => file, :multipart => true }

  res_name = "upload#{id}instrumentation#{digest}"
  extra_headers = {'X-Testdroid-MD5' => digest}

  @client.post_api_request(endpoint, params, res_name, extra_headers )
end