From 7726e9fe1ddeb980efd197bc6b1b4281f1eef62b Mon Sep 17 00:00:00 2001 From: Sakari Rautiainen Date: Mon, 22 Oct 2018 15:45:27 -0700 Subject: [PATCH 1/2] Removed question mark from request --- testdroid/tests/test_all.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdroid/tests/test_all.py b/testdroid/tests/test_all.py index 6813a76..ebeb659 100644 --- a/testdroid/tests/test_all.py +++ b/testdroid/tests/test_all.py @@ -167,7 +167,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, From e5232833fe671f279ec3297c81af403081bd52a8 Mon Sep 17 00:00:00 2001 From: Sakari Rautiainen Date: Mon, 22 Oct 2018 16:16:35 -0700 Subject: [PATCH 2/2] Fix for delete param path, added tests --- testdroid/__init__.py | 2 +- testdroid/tests/test_all.py | 50 ++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/testdroid/__init__.py b/testdroid/__init__.py index 788fbce..4e68028 100755 --- a/testdroid/__init__.py +++ b/testdroid/__init__.py @@ -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 diff --git a/testdroid/tests/test_all.py b/testdroid/tests/test_all.py index ebeb659..e8d1c04 100644 --- a/testdroid/tests/test_all.py +++ b/testdroid/tests/test_all.py @@ -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() @@ -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) + +