Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion testdroid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def upload_test_file(self, project_id, filename):
"""
def delete_project_parameters(self, project_id, parameter_id):
me = self.get_me()
path = "/users/%s/projects/%s/config/parameters/%s" % ( me['id'], project_id, parameter_id )
path = "users/%s/projects/%s/config/parameters/%s" % ( me['id'], project_id, parameter_id )
return self.delete(path=path)

""" Get project parameters
Expand Down
52 changes: 47 additions & 5 deletions testdroid/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@
import testdroid
import responses

URL_BASE = 'https://cloud.bitbar.com'
URL_API = '{}/api/v2'.format(URL_BASE)
URL_API_ME = '{}/me'.format(URL_API)
URL_USERS = '{}/users'.format(URL_BASE)
JSON = {'k': 'v'}
PROJECT_ID = 2
TEST_RUN_ID = 3
DEVICE_RUN_ID = 4
DEVICE_SESSION_ID = 5
DEVICE_GROUP_ID = 6
USER_ID = 7
PARAM_ID = 8
TAGS = 'tags'
LIMIT = 0


URL_BASE = 'https://cloud.bitbar.com'
URL_API = '{}/api/v2'.format(URL_BASE)
URL_API_ME = '{}/me'.format(URL_API)
URL_USERS = '{}/users/{}'.format(URL_API,USER_ID)

t = testdroid.Testdroid()


Expand Down Expand Up @@ -167,7 +172,7 @@ def test_get_device_run_files_without_tags(self):

@responses.activate
def test_get_device_run_files_with_tags(self):
url = '{}/projects/{}/runs/{}/device-sessions/{}/output-file-set/files?tag[]?={}'.format(
url = '{}/projects/{}/runs/{}/device-sessions/{}/output-file-set/files?tag[]={}'.format(
URL_API_ME, PROJECT_ID, TEST_RUN_ID, DEVICE_SESSION_ID, TAGS)
responses.add(responses.GET, url, json=JSON, status=200)
response = t.get_device_run_files(PROJECT_ID, TEST_RUN_ID,
Expand All @@ -180,3 +185,40 @@ def test_get_input_files(self):
URL_API_ME, LIMIT)
responses.add(responses.GET, url, json=JSON, status=200)
self.assertEqual(t.get_input_files(LIMIT), JSON)

@responses.activate
def test_start_test_run(self):
url = '{}/projects/2'.format(
URL_API_ME)
json = {
'id': USER_ID,
'name': 'Sample project',
}
responses.add(responses.GET, url, json=json, status=200)

responses.add(responses.GET, URL_API_ME, json=json, status=200)
url = '{}/projects/{}/runs'.format(
URL_USERS, PROJECT_ID)
json = {
'id': 12,
'displayName': "My test run"
}


responses.add(responses.POST, url, json=json, status=201)
self.assertEqual(t.start_test_run(PROJECT_ID, DEVICE_GROUP_ID), json['id'])

@responses.activate
def test_delete_project_parameters(self):
path = 'projects/{}/config/parameters/{}'.format(PROJECT_ID, PARAM_ID)
url = '{}/{}'.format(URL_USERS, path)

json = {
'id': USER_ID
}
responses.add(responses.GET, URL_API_ME, json=json, status=200)
responses.add(responses.DELETE, url, json=JSON, status=204)
response = t.delete_project_parameters(PROJECT_ID, PARAM_ID)
self.assertEqual(response.status_code, 204)