summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/testapi-client/testapiclient')
-rw-r--r--testapi/testapi-client/testapiclient/cli/deployresults.py12
-rw-r--r--testapi/testapi-client/testapiclient/cli/pods.py7
-rw-r--r--testapi/testapi-client/testapiclient/cli/projects.py15
-rw-r--r--testapi/testapi-client/testapiclient/cli/results.py9
-rw-r--r--testapi/testapi-client/testapiclient/cli/scenarios.py147
-rw-r--r--testapi/testapi-client/testapiclient/cli/testcases.py19
-rw-r--r--testapi/testapi-client/testapiclient/client/deploy_results.py28
-rw-r--r--testapi/testapi-client/testapiclient/client/pods.py20
-rw-r--r--testapi/testapi-client/testapiclient/client/projects.py35
-rw-r--r--testapi/testapi-client/testapiclient/client/results.py28
-rw-r--r--testapi/testapi-client/testapiclient/client/scenarios.py177
-rw-r--r--testapi/testapi-client/testapiclient/client/testcases.py36
-rw-r--r--testapi/testapi-client/testapiclient/models/deployresult.py17
-rw-r--r--testapi/testapi-client/testapiclient/models/pods.py2
-rw-r--r--testapi/testapi-client/testapiclient/models/project.py4
-rw-r--r--testapi/testapi-client/testapiclient/models/result.py16
-rw-r--r--testapi/testapi-client/testapiclient/models/scenario.py37
-rw-r--r--testapi/testapi-client/testapiclient/models/testcase.py20
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_deployresults_client.py81
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_pod_client.py89
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_project_client.py111
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_results_client.py78
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_scenario_client.py104
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_scenario_custom_client.py106
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_scenario_installer_client.py86
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_scenario_project_client.py104
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_scenario_score_client.py53
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_scenario_trust_indicator_client.py53
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_scenario_version_client.py96
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_testcase_client.py118
30 files changed, 1621 insertions, 87 deletions
diff --git a/testapi/testapi-client/testapiclient/cli/deployresults.py b/testapi/testapi-client/testapiclient/cli/deployresults.py
index a6fe13e..1ca0bef 100644
--- a/testapi/testapi-client/testapiclient/cli/deployresults.py
+++ b/testapi/testapi-client/testapiclient/cli/deployresults.py
@@ -2,6 +2,7 @@ import json
from testapiclient.utils import command
from testapiclient.utils import urlparse
+from testapiclient.models import deployresult
def deployresults_url():
@@ -85,13 +86,10 @@ class DeployresultCreate(command.ShowOne):
parser.add_argument('deployresult',
type=json.loads,
help='Deployresult create request format:\n'
- '\'{"job_name" : "","scenario" : "",'
- '"stop_date" : "", "build_id" : "",'
- '"upstream_job_name": "",'
- '"version" : "", "pod_name" : "",'
- '"criteria" : "", "installer" : "",'
- '"upstream_build_id" : "",'
- '"start_date" : "", "details" : ""}\'')
+ '\'{}\''.format(json.dumps(
+ deployresult.DeployResultCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
diff --git a/testapi/testapi-client/testapiclient/cli/pods.py b/testapi/testapi-client/testapiclient/cli/pods.py
index df63737..a7706f6 100644
--- a/testapi/testapi-client/testapiclient/cli/pods.py
+++ b/testapi/testapi-client/testapiclient/cli/pods.py
@@ -3,6 +3,7 @@ import json
from testapiclient.client import pods
from testapiclient.utils import command
from testapiclient.utils import urlparse
+from testapiclient.models import pods as pm
def pods_url():
@@ -61,8 +62,10 @@ class PodCreate(command.ShowOne):
parser.add_argument('pod',
type=json.loads,
help='Pod create request format :\n'
- '\'{"role": "", "name": "", "details": "", '
- '"mode": ""}\',\n role should be either '
+ '\'{}\''.format(json.dumps(
+ pm.PodCreateRequest().__dict__
+ )) +
+ '\n role should be either '
'"community-ci" or "production-ci", and '
'mode should be either "metal" or "virtual.')
return parser
diff --git a/testapi/testapi-client/testapiclient/cli/projects.py b/testapi/testapi-client/testapiclient/cli/projects.py
index 510acc8..2fa5b5b 100644
--- a/testapi/testapi-client/testapiclient/cli/projects.py
+++ b/testapi/testapi-client/testapiclient/cli/projects.py
@@ -2,6 +2,7 @@ import json
from testapiclient.utils import command
from testapiclient.utils import urlparse
+from testapiclient.models import project
def projects_url():
@@ -51,9 +52,10 @@ class ProjectCreate(command.ShowOne):
parser = super(ProjectCreate, self).get_parser(prog_name)
parser.add_argument('project',
type=json.loads,
- help='Project create request format :{'
- ' "name": (required)"", '
- '"description": (optional)""}')
+ help='Project create request format :\n'
+ '\'{}\''.format(json.dumps(
+ project.ProjectCreateRequest().__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -83,9 +85,10 @@ class ProjectPut(command.ShowOne):
help='Update project by name')
parser.add_argument('project',
type=json.loads,
- help='Project Update request format :{'
- '"name": (required)"", '
- '"description": (optional)""}')
+ help='Project Update request format :\n'
+ '\'{}\''.format(json.dumps(
+ project.ProjectCreateRequest().__dict__
+ )))
return parser
def take_action(self, parsed_args):
diff --git a/testapi/testapi-client/testapiclient/cli/results.py b/testapi/testapi-client/testapiclient/cli/results.py
index 56ea71f..5500501 100644
--- a/testapi/testapi-client/testapiclient/cli/results.py
+++ b/testapi/testapi-client/testapiclient/cli/results.py
@@ -2,6 +2,7 @@ import json
from testapiclient.utils import command
from testapiclient.utils import urlparse
+from testapiclient.models import result
def results_url():
@@ -86,12 +87,8 @@ class ResultCreate(command.ShowOne):
parser.add_argument('result',
type=json.loads,
help='Result create request format:\n'
- '\'{"project_name" : "","scenario" : "",'
- '"stop_date" : "", "case_name" : "",'
- '"build_tag" : "", "version" : "",'
- '"pod_name" : "" , "criteria" : "",'
- '"installer" : "", "start_date" : "",'
- '"details" : ""}\'')
+ '\'{}\''.format(json.dumps(
+ result.ResultCreateRequest().__dict__)))
return parser
def take_action(self, parsed_args):
diff --git a/testapi/testapi-client/testapiclient/cli/scenarios.py b/testapi/testapi-client/testapiclient/cli/scenarios.py
index 507705a..197ee0c 100644
--- a/testapi/testapi-client/testapiclient/cli/scenarios.py
+++ b/testapi/testapi-client/testapiclient/cli/scenarios.py
@@ -2,6 +2,7 @@ import json
from testapiclient.utils import command
from testapiclient.utils import urlparse
+from testapiclient.models import scenario
def scenarios_url():
@@ -64,22 +65,37 @@ class ScenarioCreate(command.ShowOne):
parser.add_argument('scenario',
type=json.loads,
help='Scenario create request format :\n'
- '\'{ "installers": [], "name": ""}\',\n'
- 'Intaller create request format :\n'
- '\'{"installer": "","versions": []}\',\n'
- 'Version create request format :\n'
- '\'{"owner": "","version": "",'
- '"projects": []}\',\n'
- 'Project create request format :\n'
- '\'{"project": "","customs": [],'
- '"scores": [],'
- '"trust_indicators": []}\',\n'
- 'Custom create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioCreateRequest(
+ ).__dict__
+ )) +
+ '\n Intaller create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioInstallerCreateRequest(
+ ).__dict__
+ )) +
+ '\n Version create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioVersionCreateRequest(
+ ).__dict__
+ )) +
+ '\n Project create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioProjectCreateRequest(
+ ).__dict__
+ )) +
+ '\n Custom create request format :\n'
'\'["asf","saf"]\',\n'
- 'Score create request format :\n'
- '\'{"date": "", "score": ""}\',\n'
- 'Trust Indicators create request format :\n'
- '\'{"date": "", "status": ""}\'')
+ '\n Score create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioScoreCreateRequest(
+ ).__dict__
+ )) +
+ '\nTrustIndicator create request format:\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioTICreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -110,23 +126,38 @@ class ScenarioPut(command.ShowOne):
help='Update scenario by name')
parser.add_argument('scenario',
type=json.loads,
- help='Scenario create request format :\n'
- '\'{ "installers": [], "name": ""}\',\n'
- 'Intaller create request format :\n'
- '\'{"installer": "","versions": []}\',\n'
- 'Version create request format :\n'
- '\'{"owner": "","version": "",'
- '"projects": []}\',\n'
- 'Project create request format :\n'
- '\'{"project": "","customs": [],'
- '"scores": [],'
- '"trust_indicators": []}\',\n'
- 'Custom create request format :\n'
+ help='Scenario create request format :\n' +
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioCreateRequest(
+ ).__dict__
+ )) +
+ '\n Intaller create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioInstallerCreateRequest(
+ ).__dict__
+ )) +
+ '\n Version create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioVersionCreateRequest(
+ ).__dict__
+ )) +
+ '\n Project create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioProjectCreateRequest(
+ ).__dict__
+ )) +
+ '\n Custom create request format :\n'
'\'["asf","saf"]\',\n'
- 'Score create request format :\n'
- '\'{"date": "", "score": ""}\',\n'
- 'Trust Indicators create request format :\n'
- '\'{"date": "", "status": ""}\'')
+ '\n Score create request format :\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioScoreCreateRequest(
+ ).__dict__
+ )) +
+ '\nTrustIndicator create request format:\n'
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioTICreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -145,7 +176,10 @@ class InstallerCreate(command.Command):
parser.add_argument('installer',
type=json.loads,
help='Intaller create request format :\n'
- '\'[{"installer": "","versions": []}]\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioInstallerCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -186,7 +220,10 @@ class InstallerPut(command.Command):
parser.add_argument('installer',
type=json.loads,
help='Intaller create request format :\n'
- '\'[{"installer": "","versions": []}]\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioInstallerCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -209,10 +246,10 @@ class VersionCreate(command.Command):
parser.add_argument('version',
type=json.loads,
help='version create request format :\n'
- '\'[{"owner":(string),'
- '"version": (string),'
- '"projects": (array[ScenarioProject])'
- '}]\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioVersionCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -261,10 +298,10 @@ class VersionPut(command.Command):
parser.add_argument('version',
type=json.loads,
help='version update request format :\n'
- '\'[{"owner":(string),'
- '"version": (string),'
- '"projects": (array[ScenarioProject])'
- '}]\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioVersionCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -320,10 +357,10 @@ class ProjectCreate(command.Command):
parser.add_argument('project',
type=json.loads,
help='Project create request format :\n'
- '\'[{ "project" (string),'
- '"scores": (array[ScenarioScore]),'
- '"trust_indicators": (array[ScenarioTI]),'
- '"customs": (array[string]) }]\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioProjectCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -378,10 +415,10 @@ class ProjectPut(command.Command):
parser.add_argument('project',
type=json.loads,
help='Project update request format :\n'
- '\'[{ "project" (string),'
- '"scores": (array[ScenarioScore]),'
- '"trust_indicators": (array[ScenarioTI]),'
- '"customs": (array[string]) }]\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioProjectCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -511,8 +548,10 @@ class TrustIndicatorCreate(command.Command):
parser.add_argument('trust_indicator',
type=json.loads,
help='trust indicator create request format :\n'
- '\'{ "date": (string, optional),'
- '"status": (string, optional) }\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioTICreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -547,8 +586,10 @@ class ScoreCreate(command.Command):
parser.add_argument('score',
type=json.loads,
help='score create request format :\n'
- '\'{ "date": (string, optional),'
- '"score" : (string, optional) }\',\n')
+ '\'{}\''.format(json.dumps(
+ scenario.ScenarioScoreCreateRequest(
+ ).__dict__
+ )))
return parser
def take_action(self, parsed_args):
diff --git a/testapi/testapi-client/testapiclient/cli/testcases.py b/testapi/testapi-client/testapiclient/cli/testcases.py
index 6c97edb..3052c18 100644
--- a/testapi/testapi-client/testapiclient/cli/testcases.py
+++ b/testapi/testapi-client/testapiclient/cli/testcases.py
@@ -2,6 +2,7 @@ import json
from testapiclient.utils import command
from testapiclient.utils import urlparse
+from testapiclient.models import testcase
def testcases_url(name):
@@ -60,12 +61,9 @@ class TestcaseCreate(command.ShowOne):
parser.add_argument('testcase',
type=json.loads,
help='Testcase create request format:\n'
- '\'{"run": "", "name": "", "ci_loop": "",'
- '"tags": "",\n "url": "", "blocking": "",'
- '"domains": "", "dependencies": "",\n '
- '"version": "", "criteria": "", "tier": "",'
- '"trust": "",\n "catalog_description": "",'
- '"description": ""}\'')
+ '\'{}\''.format(json.dumps(
+ testcase.TestCaseCreateRequest().__dict__
+ )))
return parser
def take_action(self, parsed_args):
@@ -105,12 +103,9 @@ class TestcasePut(command.ShowOne):
parser.add_argument('testcase',
type=json.loads,
help='Testcase Update request format:\n'
- '\'{"run": "", "name": "", "ci_loop": "",'
- '"tags": "",\n "url": "", "blocking": "",'
- '"domains": "", "dependencies": "",\n '
- '"version": "", "criteria": "", "tier": "",'
- '"trust": "",\n "catalog_description": "",'
- '"description": ""}\'')
+ '\'{}\''.format(json.dumps(
+ testcase.TestCaseCreateRequest().__dict__
+ )))
return parser
def take_action(self, parsed_args):
diff --git a/testapi/testapi-client/testapiclient/client/deploy_results.py b/testapi/testapi-client/testapiclient/client/deploy_results.py
new file mode 100644
index 0000000..b0724b0
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/client/deploy_results.py
@@ -0,0 +1,28 @@
+import json
+
+from testapiclient.client import base
+from testapiclient.utils import urlparse
+
+
+class DeployResultsClient(base.Client):
+ resource = 'deployresults'
+
+ def __init__(self, **kwargs):
+ super(DeployResultsClient, self).__init__(**kwargs)
+
+ def create(self, testcase_req):
+ return self.clientmanager.post(self.url, testcase_req)
+
+ def get(self, **queries):
+ if queries:
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.query_join(self.url, **queries))['deployresults'])
+ else:
+ return json.dumps(
+ self.clientmanager.get(self.url)['deployresults'])
+
+ def get_one(self, id):
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.path_join(self.url, id)))
diff --git a/testapi/testapi-client/testapiclient/client/pods.py b/testapi/testapi-client/testapiclient/client/pods.py
index 4254da7..d08114f 100644
--- a/testapi/testapi-client/testapiclient/client/pods.py
+++ b/testapi/testapi-client/testapiclient/client/pods.py
@@ -1,4 +1,7 @@
+import json
+
from testapiclient.client import base
+from testapiclient.utils import urlparse
class PodsClient(base.Client):
@@ -9,3 +12,20 @@ class PodsClient(base.Client):
def create(self, pod_req):
return self.clientmanager.post(self.url, pod_req)
+
+ def get(self, **queries):
+ if queries:
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.query_join(self.url, **queries))['pods'])
+ else:
+ return json.dumps(
+ self.clientmanager.get(self.url)['pods'])
+
+ def get_one(self, name):
+ return json.dumps(self.clientmanager.get(
+ urlparse.path_join(self.url, name)))
+
+ def delete(self, name):
+ return self.clientmanager.delete(
+ urlparse.path_join(self.url, name))
diff --git a/testapi/testapi-client/testapiclient/client/projects.py b/testapi/testapi-client/testapiclient/client/projects.py
new file mode 100644
index 0000000..63d00fe
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/client/projects.py
@@ -0,0 +1,35 @@
+import json
+
+from testapiclient.client import base
+from testapiclient.utils import urlparse
+
+
+class ProjectsClient(base.Client):
+ resource = 'projects'
+
+ def __init__(self, **kwargs):
+ super(ProjectsClient, self).__init__(**kwargs)
+
+ def create(self, project_req):
+ return self.clientmanager.post(self.url, project_req)
+
+ def get(self, **queries):
+ if queries:
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.query_join(self.url, **queries))['projects'])
+ else:
+ return json.dumps(
+ self.clientmanager.get(self.url)['projects'])
+
+ def get_one(self, name):
+ return json.dumps(self.clientmanager.get(
+ urlparse.path_join(self.url, name)))
+
+ def delete(self, name):
+ return self.clientmanager.delete(
+ urlparse.path_join(self.url, name))
+
+ def update(self, name, project_req):
+ return self.clientmanager.put(
+ urlparse.path_join(self.url, name), project_req)
diff --git a/testapi/testapi-client/testapiclient/client/results.py b/testapi/testapi-client/testapiclient/client/results.py
new file mode 100644
index 0000000..7d9ad0e
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/client/results.py
@@ -0,0 +1,28 @@
+import json
+
+from testapiclient.client import base
+from testapiclient.utils import urlparse
+
+
+class ResultsClient(base.Client):
+ resource = 'results'
+
+ def __init__(self, **kwargs):
+ super(ResultsClient, self).__init__(**kwargs)
+
+ def create(self, testcase_req):
+ return self.clientmanager.post(self.url, testcase_req)
+
+ def get(self, **queries):
+ if queries:
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.query_join(self.url, **queries))['results'])
+ else:
+ return json.dumps(
+ self.clientmanager.get(self.url)['results'])
+
+ def get_one(self, id):
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.path_join(self.url, id)))
diff --git a/testapi/testapi-client/testapiclient/client/scenarios.py b/testapi/testapi-client/testapiclient/client/scenarios.py
new file mode 100644
index 0000000..e5ce2f1
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/client/scenarios.py
@@ -0,0 +1,177 @@
+import json
+
+from testapiclient.client import base
+from testapiclient.utils import urlparse
+
+
+class ScenariosClient(base.Client):
+ resource = 'scenarios'
+
+ def __init__(self, **kwargs):
+ super(ScenariosClient, self).__init__(**kwargs)
+
+ def create(self, scenario_req):
+ return self.clientmanager.post(self.url, scenario_req)
+
+ def get(self, **queries):
+ if queries:
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.query_join(self.url, **queries))['scenarios'])
+ else:
+ return json.dumps(
+ self.clientmanager.get(self.url)['scenarios'])
+
+ def get_one(self, scenario_name):
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.path_join(
+ self.url, scenario_name)))
+
+ def delete(self, scenario_name):
+ return self.clientmanager.delete(
+ urlparse.path_join(
+ self.url, scenario_name))
+
+ def update(self, scenario_name, scenario_req):
+ return self.clientmanager.put(
+ urlparse.path_join(
+ self.url, scenario_name), scenario_req)
+
+
+class InstallersClient(base.Client):
+ resource = 'scenarios/{}/installers'
+
+ def __init__(self, **kwargs):
+ super(InstallersClient, self).__init__(**kwargs)
+
+ def delete(self, scenario_name, name):
+ return self.clientmanager.delete(
+ self.url.format(scenario_name), [name])
+
+ def update(self, scenario_name, installer_req):
+ return self.clientmanager.put(
+ self.url.format(scenario_name), installer_req)
+
+ def create(self, scenario_name, installer_req):
+ return self.clientmanager.post(
+ self.url.format(scenario_name), installer_req)
+
+
+class VersionsClient(base.Client):
+ resource = 'scenarios/{}/versions'
+
+ def __init__(self, **kwargs):
+ super(VersionsClient, self).__init__(**kwargs)
+
+ def delete(self, scenario_name, installer, name):
+ queries = {'installer': installer}
+ return self.clientmanager.delete(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), name)
+
+ def update(self, scenario_name, installer, version_req):
+ queries = {'installer': installer}
+ return self.clientmanager.put(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), version_req)
+
+ def create(self, scenario_name, installer, version_req):
+ queries = {'installer': installer}
+ return self.clientmanager.post(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), version_req)
+
+
+class VersionsOwnerClient(base.Client):
+ resource = 'scenarios/{}/owner'
+
+ def __init__(self, **kwargs):
+ super(VersionsOwnerClient, self).__init__(**kwargs)
+
+ def update(self, scenario_name, installer, version, owner):
+ queries = {'installer': installer, 'version': version}
+ return self.clientmanager.put(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), owner)
+
+
+class ProjectsClient(base.Client):
+ resource = 'scenarios/{}/projects'
+
+ def __init__(self, **kwargs):
+ super(ProjectsClient, self).__init__(**kwargs)
+
+ def delete(self, scenario_name, installer, version, name):
+ queries = {'installer': installer, 'version': version}
+ return self.clientmanager.delete(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), name)
+
+ def update(self, scenario_name, installer, version, project_req):
+ queries = {'installer': installer, 'version': version}
+ return self.clientmanager.put(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), project_req)
+
+ def create(self, scenario_name, installer, version, project_req):
+ queries = {'installer': installer, 'version': version}
+ return self.clientmanager.post(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), project_req)
+
+
+class TrustIndicatorsClient(base.Client):
+ resource = 'scenarios/{}/trust_indicators'
+
+ def __init__(self, **kwargs):
+ super(TrustIndicatorsClient, self).__init__(**kwargs)
+
+ def create(self, scenario_name, installer, version, project, trust_in_req):
+ queries = {
+ 'installer': installer, 'version': version, 'project': project}
+ return self.clientmanager.post(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), trust_in_req)
+
+
+class ScoresClient(base.Client):
+ resource = 'scenarios/{}/scores'
+
+ def __init__(self, **kwargs):
+ super(ScoresClient, self).__init__(**kwargs)
+
+ def create(self, scenario_name, installer, version, project, scores_req):
+ queries = {
+ 'installer': installer, 'version': version, 'project': project}
+ return self.clientmanager.post(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), scores_req)
+
+
+class CustomsClient(base.Client):
+ resource = 'scenarios/{}/customs'
+
+ def __init__(self, **kwargs):
+ super(CustomsClient, self).__init__(**kwargs)
+
+ def delete(self, scenario_name, installer, version, project, customs):
+ queries = {
+ 'installer': installer, 'version': version, 'project': project}
+ return self.clientmanager.delete(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), customs)
+
+ def update(self, scenario_name, installer, version, project, customs):
+ queries = {
+ 'installer': installer, 'version': version, 'project': project}
+ return self.clientmanager.put(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), customs)
+
+ def create(self, scenario_name, installer, version, project, customs):
+ queries = {
+ 'installer': installer, 'version': version, 'project': project}
+ return self.clientmanager.post(
+ urlparse.query_join(
+ self.url.format(scenario_name), **queries), customs)
diff --git a/testapi/testapi-client/testapiclient/client/testcases.py b/testapi/testapi-client/testapiclient/client/testcases.py
new file mode 100644
index 0000000..bb2b6d3
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/client/testcases.py
@@ -0,0 +1,36 @@
+import json
+
+from testapiclient.client import base
+from testapiclient.utils import urlparse
+
+
+class TestcasesClient(base.Client):
+ resource = 'projects/{}/cases'
+
+ def __init__(self, **kwargs):
+ super(TestcasesClient, self).__init__(**kwargs)
+
+ def create(self, project_name, testcase_req):
+ return self.clientmanager.post(
+ self.url.format(project_name), testcase_req)
+
+ def get(self, project_name):
+ return json.dumps(
+ self.clientmanager.get(
+ self.url.format(project_name))['testcases'])
+
+ def get_one(self, project_name, name):
+ return json.dumps(
+ self.clientmanager.get(
+ urlparse.path_join(
+ self.url.format(project_name), name)))
+
+ def delete(self, project_name, name):
+ return self.clientmanager.delete(
+ urlparse.path_join(
+ self.url.format(project_name), name))
+
+ def update(self, project_name, name, testcase_req):
+ return self.clientmanager.put(
+ urlparse.path_join(
+ self.url.format(project_name), name), testcase_req)
diff --git a/testapi/testapi-client/testapiclient/models/deployresult.py b/testapi/testapi-client/testapiclient/models/deployresult.py
new file mode 100644
index 0000000..5c13966
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/models/deployresult.py
@@ -0,0 +1,17 @@
+class DeployResultCreateRequest():
+ def __init__(
+ self, build_id='', scenario='', stop_date='', start_date='',
+ upstream_job_name='', version='', pod_name='', criteria='',
+ installer='', upstream_build_id='', job_name='', details=''):
+ self.build_id = build_id
+ self.scenario = scenario
+ self.stop_date = stop_date
+ self.start_date = start_date
+ self.upstream_job_name = upstream_job_name
+ self.version = version
+ self.pod_name = pod_name
+ self.criteria = criteria
+ self.installer = installer
+ self.upstream_build_id = upstream_build_id
+ self.job_name = job_name
+ self.details = details
diff --git a/testapi/testapi-client/testapiclient/models/pods.py b/testapi/testapi-client/testapiclient/models/pods.py
index 27ea311..4fa42e7 100644
--- a/testapi/testapi-client/testapiclient/models/pods.py
+++ b/testapi/testapi-client/testapiclient/models/pods.py
@@ -1,5 +1,5 @@
class PodCreateRequest(object):
- def __init__(self, name='', mode='', details='', role=""):
+ def __init__(self, name='', mode='', details='', role=''):
self.name = name
self.mode = mode
self.details = details
diff --git a/testapi/testapi-client/testapiclient/models/project.py b/testapi/testapi-client/testapiclient/models/project.py
new file mode 100644
index 0000000..fc85588
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/models/project.py
@@ -0,0 +1,4 @@
+class ProjectCreateRequest():
+ def __init__(self, name='', description=''):
+ self.description = description
+ self.name = name
diff --git a/testapi/testapi-client/testapiclient/models/result.py b/testapi/testapi-client/testapiclient/models/result.py
new file mode 100644
index 0000000..766c03a
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/models/result.py
@@ -0,0 +1,16 @@
+class ResultCreateRequest():
+ def __init__(
+ self, project_name='', scenario='', case_name='', pod_name='',
+ installer='', version='', stop_date='', build_tag='', criteria='',
+ start_date='', details=''):
+ self.project_name = project_name
+ self.scenario = scenario
+ self.case_name = case_name
+ self.pod_name = pod_name
+ self.installer = installer
+ self.version = version
+ self.stop_date = stop_date
+ self.build_tag = build_tag
+ self.criteria = criteria
+ self.start_date = start_date
+ self.details = details
diff --git a/testapi/testapi-client/testapiclient/models/scenario.py b/testapi/testapi-client/testapiclient/models/scenario.py
new file mode 100644
index 0000000..f4f0f40
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/models/scenario.py
@@ -0,0 +1,37 @@
+class ScenarioCreateRequest:
+ def __init__(self, name='', installers=[]):
+ self.name = name
+ self.installers = installers
+
+
+class ScenarioInstallerCreateRequest:
+ def __init__(self, installer='', versions=[]):
+ self.installer = installer
+ self.versions = versions
+
+
+class ScenarioVersionCreateRequest:
+ def __init__(self, version='', owner='', projects=[]):
+ self.version = version
+ self.owner = owner
+ self.projects = projects
+
+
+class ScenarioProjectCreateRequest:
+ def __init__(self, project='', scores=[], trust_indicators=[], customs=[]):
+ self.project = project
+ self.scores = scores
+ self.trust_indicators = trust_indicators
+ self.customs = customs
+
+
+class ScenarioScoreCreateRequest:
+ def __init__(self, score='', date=''):
+ self.score = score
+ self.date = date
+
+
+class ScenarioTICreateRequest:
+ def __init__(self, status='', date=''):
+ self.status = status
+ self.date = date
diff --git a/testapi/testapi-client/testapiclient/models/testcase.py b/testapi/testapi-client/testapiclient/models/testcase.py
new file mode 100644
index 0000000..70d5d78
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/models/testcase.py
@@ -0,0 +1,20 @@
+class TestCaseCreateRequest():
+ def __init__(
+ self, run='', name='', ci_loop='', tags='', url='',
+ blocking='', domains='', dependencies='', version='',
+ criteria='', tier='', trust='', catalog_description='',
+ description=''):
+ self.run = run
+ self.name = name
+ self.ci_loop = ci_loop
+ self.tags = tags
+ self.url = url
+ self.blocking = blocking
+ self.domains = domains
+ self.dependencies = dependencies
+ self.version = version
+ self.criteria = criteria
+ self.tier = tier
+ self.trust = trust
+ self.catalog_description = catalog_description
+ self.description = description
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_deployresults_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_deployresults_client.py
new file mode 100644
index 0000000..03288fe
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_deployresults_client.py
@@ -0,0 +1,81 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import deploy_results
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class DeployResultsClientTest(utils.TestCommand):
+ def setUp(self):
+ super(DeployResultsClientTest, self).setUp()
+ self.base_url = parse.urljoin(self.api_url, 'deployresults')
+ self.deployresult_json = {
+ 'project_name': 'functest',
+ 'scenario': 'test-scenario',
+ 'stop_date': '2018-04-09 13:44:53',
+ 'case_name': 'test-case',
+ 'build_tag': 'test-build',
+ 'version': 'test-version',
+ 'pod_name': 'test-pod',
+ 'criteria': 'test-criteria',
+ 'installer': 'test-installer',
+ 'start_date': '2018-04-09 13:44:53',
+ 'details': 'test-details'
+ }
+ self.deployresult_id = '5a6dc1089a07c80f3c9f8d62'
+ self.deployresult_string = json.dumps(self.deployresult_json)
+ self.deployresult_client = deploy_results.DeployResultsClient()
+
+
+class DeployResultsClientGetTest(DeployResultsClientTest):
+
+ def setUp(self):
+ super(DeployResultsClientGetTest, self).setUp()
+ self.deployresults_rsp = {'deployresults': [self.deployresult_json]}
+
+ def test_get(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.deployresults_rsp)
+ self.deployresult_client.get()
+ self.get_mock.assert_called_once_with(
+ self.base_url,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_search(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.deployresults_rsp)
+ self.deployresult_client.get(name='deployresult1')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '?name=deployresult1',
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_one(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.deployresult_json)
+ self.deployresult_client.get_one('2333')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '/2333',
+ headers=clientmanager.ClientManager.headers)
+
+
+class DeployResultsClientCreateTest(DeployResultsClientTest):
+
+ def setUp(self):
+ super(DeployResultsClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(self.base_url, self.deployresult_id)
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(data=self.succ_rsp)
+ self.deployresult_client.create(self.deployresult_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.deployresult_client.create(self.deployresult_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_pod_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_pod_client.py
new file mode 100644
index 0000000..1df5660
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_pod_client.py
@@ -0,0 +1,89 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import pods
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class PodClientTest(utils.TestCommand):
+ def setUp(self):
+ super(PodClientTest, self).setUp()
+ self.base_url = parse.urljoin(self.api_url, 'pods')
+ self.pod_json = {
+ 'role': 'community-ci',
+ 'name': 'test_pod',
+ 'details': '',
+ 'mode': 'metal'
+ }
+ self.pod_client = pods.PodsClient()
+ self.pod_string = json.dumps(self.pod_json)
+
+
+class PodClientGetTest(PodClientTest):
+
+ def setUp(self):
+ super(PodClientGetTest, self).setUp()
+ self.pods_rsp = {'pods': [self.pod_json]}
+
+ def test_get(self):
+ self.get_mock.return_value = fakes.FakeResponse(data=self.pods_rsp)
+ self.pod_client.get()
+ self.get_mock.assert_called_once_with(
+ self.base_url,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_search(self):
+ self.get_mock.return_value = fakes.FakeResponse(data=self.pods_rsp)
+ self.pod_client.get(name='pod1')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '?name=pod1',
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_one(self):
+ self.get_mock.return_value = fakes.FakeResponse(data=self.pod_json)
+ self.pod_client.get_one('def')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '/def',
+ headers=clientmanager.ClientManager.headers)
+
+
+class PodClientCreateTest(PodClientTest):
+
+ def setUp(self):
+ super(PodClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(self.base_url, self.pod_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(data=self.succ_rsp)
+ self.pod_client.create(self.pod_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.pod_client.create(self.pod_json)
+
+
+class PodClientDeleteTest(PodClientTest):
+
+ def setUp(self):
+ super(PodClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.pod_client.delete('def')
+ self.delete_mock.assert_called_once_with(
+ self.base_url + '/def',
+ data=None,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.pod_client.delete('def')
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_project_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_project_client.py
new file mode 100644
index 0000000..7aa11e6
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_project_client.py
@@ -0,0 +1,111 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import projects
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class ProjectClientTest(utils.TestCommand):
+ def setUp(self):
+ super(ProjectClientTest, self).setUp()
+ self.base_url = parse.urljoin(self.api_url, 'projects')
+ self.project_json = {
+ 'description': 'test_description',
+ 'name': 'test_project',
+ }
+ self.project_client = projects.ProjectsClient()
+ self.project_string = json.dumps(self.project_json)
+
+
+class ProjectClientGetTest(ProjectClientTest):
+
+ def setUp(self):
+ super(ProjectClientGetTest, self).setUp()
+ self.projects_rsp = {'projects': [self.project_json]}
+
+ def test_get(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.projects_rsp)
+ self.project_client.get()
+ self.get_mock.assert_called_once_with(
+ self.base_url,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_search(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.projects_rsp)
+ self.project_client.get(name='project1')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '?name=project1',
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_one(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.project_json)
+ self.project_client.get_one('def')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '/def',
+ headers=clientmanager.ClientManager.headers)
+
+
+class ProjectClientCreateTest(ProjectClientTest):
+
+ def setUp(self):
+ super(ProjectClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.project_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.project_client.create(self.project_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.project_client.create(self.project_json)
+
+
+class ProjectClientDeleteTest(ProjectClientTest):
+
+ def setUp(self):
+ super(ProjectClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.project_client.delete('def')
+ self.delete_mock.assert_called_once_with(
+ self.base_url + '/def',
+ data=None,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.project_client.delete('def')
+
+
+class ProjectClientUpdateTest(ProjectClientTest):
+
+ def setUp(self):
+ super(ProjectClientUpdateTest, self).setUp()
+
+ def test_update_success(self):
+ self.put_mock.return_value = fakes.FakeResponse()
+ self.project_client.update('def', self.project_json)
+ self.put_mock.assert_called_once_with(
+ self.base_url + '/def',
+ data=self.project_string,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_update_failure(self):
+ with testtools.ExpectedException(Exception, 'Update failed: Error'):
+ self.put_mock.return_value = utils.FAKE_FAILURE
+ self.project_client.update('def', self.project_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_results_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_results_client.py
new file mode 100644
index 0000000..ae677f7
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_results_client.py
@@ -0,0 +1,78 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import results
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class ResultClientTest(utils.TestCommand):
+ def setUp(self):
+ super(ResultClientTest, self).setUp()
+ self.base_url = parse.urljoin(self.api_url, 'results')
+ self.result_json = {
+ 'project_name': 'functest',
+ 'scenario': 'test-scenario',
+ 'stop_date': '2018-04-09 13:44:53',
+ 'case_name': 'test-case',
+ 'build_tag': 'test-build',
+ 'version': 'test-version',
+ 'pod_name': 'test-pod',
+ 'criteria': 'test-criteria',
+ 'installer': 'test-installer',
+ 'start_date': '2018-04-09 13:44:53',
+ 'details': 'test-details'
+ }
+ self.result_id = '5a6dc1089a07c80f3c9f8d62'
+ self.result_string = json.dumps(self.result_json)
+ self.result_client = results.ResultsClient()
+
+
+class ResultClientGetTest(ResultClientTest):
+
+ def setUp(self):
+ super(ResultClientGetTest, self).setUp()
+ self.results_rsp = {'results': [self.result_json]}
+
+ def test_get(self):
+ self.get_mock.return_value = fakes.FakeResponse(data=self.results_rsp)
+ self.result_client.get()
+ self.get_mock.assert_called_once_with(
+ self.base_url,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_search(self):
+ self.get_mock.return_value = fakes.FakeResponse(data=self.results_rsp)
+ self.result_client.get(name='result1')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '?name=result1',
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_one(self):
+ self.get_mock.return_value = fakes.FakeResponse(data=self.result_json)
+ self.result_client.get_one('2333')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '/2333',
+ headers=clientmanager.ClientManager.headers)
+
+
+class ResultClientCreateTest(ResultClientTest):
+
+ def setUp(self):
+ super(ResultClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(self.base_url, self.result_id)
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(data=self.succ_rsp)
+ self.result_client.create(self.result_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.result_client.create(self.result_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_scenario_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_client.py
new file mode 100644
index 0000000..6e9e0fa
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_client.py
@@ -0,0 +1,104 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import scenarios
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class ScenarioClientTest(utils.TestCommand):
+ def setUp(self):
+ super(ScenarioClientTest, self).setUp()
+ self.base_url = parse.urljoin(self.api_url, 'scenarios')
+ self.scenario_json = {
+ "installers": [],
+ "name": "test_scenario"
+ }
+ self.scenario_client = scenarios.ScenariosClient()
+ self.scenario_string = json.dumps(self.scenario_json)
+
+
+class ScenarioClientGetTest(ScenarioClientTest):
+
+ def setUp(self):
+ super(ScenarioClientGetTest, self).setUp()
+ self.scenarios_rsp = {'scenarios': [self.scenario_json]}
+
+ def test_get(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.scenarios_rsp)
+ self.scenario_client.get()
+ self.get_mock.assert_called_once_with(
+ self.base_url,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_one(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.scenario_json)
+ self.scenario_client.get_one('def')
+ self.get_mock.assert_called_once_with(
+ self.base_url + '/def',
+ headers=clientmanager.ClientManager.headers)
+
+
+class ScenarioClientCreateTest(ScenarioClientTest):
+
+ def setUp(self):
+ super(ScenarioClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.scenario_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.scenario_client.create(self.scenario_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.scenario_client.create(self.scenario_json)
+
+
+class ScenarioClientDeleteTest(ScenarioClientTest):
+
+ def setUp(self):
+ super(ScenarioClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.scenario_client.delete('def')
+ self.delete_mock.assert_called_once_with(
+ self.base_url + '/def',
+ data=None,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.scenario_client.delete('def')
+
+
+class ScenarioClientUpdateTest(ScenarioClientTest):
+
+ def setUp(self):
+ super(ScenarioClientUpdateTest, self).setUp()
+
+ def test_update_success(self):
+ self.put_mock.return_value = fakes.FakeResponse()
+ self.scenario_client.update(
+ 'def', self.scenario_json)
+ self.put_mock.assert_called_once_with(
+ self.base_url + '/def',
+ data=self.scenario_string,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_update_failure(self):
+ with testtools.ExpectedException(Exception, 'Update failed: Error'):
+ self.put_mock.return_value = utils.FAKE_FAILURE
+ self.scenario_client.update('def', self.scenario_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_scenario_custom_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_custom_client.py
new file mode 100644
index 0000000..7c6d62c
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_custom_client.py
@@ -0,0 +1,106 @@
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import scenarios
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+
+
+class CustomClientTest(utils.TestCommand):
+ def setUp(self):
+ super(CustomClientTest, self).setUp()
+ self.scenario_name = 'scenrio1'
+ self.base_url = parse.urljoin(
+ self.api_url,
+ 'scenarios/{}/customs'.format(self.scenario_name))
+ self.custom_raw = 'custom'
+ self.custom_input = ['custom']
+ self.installer_name = 'installer'
+ self.version_name = 'version'
+ self.project_name = 'project'
+ self.custom_client = scenarios.CustomsClient()
+
+
+class CustomClientCreateTest(CustomClientTest):
+
+ def setUp(self):
+ super(CustomClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.scenario_name)
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.custom_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.custom_raw)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.custom_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.custom_raw)
+
+
+class CustomClientDeleteTest(CustomClientTest):
+
+ def setUp(self):
+ super(CustomClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.custom_client.delete(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.custom_raw)
+ kall = self.delete_mock.call_args
+ args, kwargs = kall
+ self.assert_url(
+ args[0],
+ self.base_url +
+ '?installer=installer&version=version&project=project')
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.custom_client.delete(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.custom_raw)
+
+
+class CustomClientUpdateTest(CustomClientTest):
+
+ def setUp(self):
+ super(CustomClientUpdateTest, self).setUp()
+
+ def test_update_success(self):
+ self.put_mock.return_value = fakes.FakeResponse()
+ self.custom_client.update(
+ self.scenario_name,
+ self.installer_name,
+ self.version_name,
+ self.project_name,
+ self.custom_raw)
+ kall = self.put_mock.call_args
+ args, kwargs = kall
+ self.assert_url(
+ args[0],
+ self.base_url +
+ '?installer=installer&version=version&project=project')
+
+ def test_update_failure(self):
+ with testtools.ExpectedException(Exception, 'Update failed: Error'):
+ self.put_mock.return_value = utils.FAKE_FAILURE
+ self.custom_client.update(
+ self.scenario_name,
+ self.installer_name,
+ self.version_name,
+ self.project_name,
+ self.custom_raw)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_scenario_installer_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_installer_client.py
new file mode 100644
index 0000000..71ba150
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_installer_client.py
@@ -0,0 +1,86 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import scenarios
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class InstallerClientTest(utils.TestCommand):
+ def setUp(self):
+ super(InstallerClientTest, self).setUp()
+ self.scenario_name = 'scenrio1'
+ self.base_url = parse.urljoin(
+ self.api_url,
+ 'scenarios/{}/installers'.format(self.scenario_name))
+ self.installer_json = {
+ 'versions': [],
+ 'installer': 'test-installer',
+ }
+ self.installer_client = scenarios.InstallersClient()
+ self.installer_string = json.dumps(self.installer_json)
+
+
+class InstallerClientCreateTest(InstallerClientTest):
+
+ def setUp(self):
+ super(InstallerClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.installer_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.installer_client.create(self.scenario_name, self.installer_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.installer_client.create(
+ self.scenario_name, self.installer_json)
+
+
+class InstallerClientDeleteTest(InstallerClientTest):
+
+ def setUp(self):
+ super(InstallerClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.installer_client.delete(self.scenario_name, 'def')
+ self.delete_mock.assert_called_once_with(
+ self.base_url,
+ data=json.dumps(['def']),
+ headers=clientmanager.ClientManager.headers)
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.installer_client.delete(self.scenario_name, 'def')
+
+
+class InstallerClientUpdateTest(InstallerClientTest):
+
+ def setUp(self):
+ super(InstallerClientUpdateTest, self).setUp()
+
+ def test_update_success(self):
+ self.put_mock.return_value = fakes.FakeResponse()
+ self.installer_client.update(
+ self.scenario_name,
+ self.installer_json)
+ self.put_mock.assert_called_once_with(
+ self.base_url,
+ data=self.installer_string,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_update_failure(self):
+ with testtools.ExpectedException(Exception, 'Update failed: Error'):
+ self.put_mock.return_value = utils.FAKE_FAILURE
+ self.installer_client.update('def', self.installer_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_scenario_project_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_project_client.py
new file mode 100644
index 0000000..f8c3d60
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_project_client.py
@@ -0,0 +1,104 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import scenarios
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+
+
+class ProjectClientTest(utils.TestCommand):
+ def setUp(self):
+ super(ProjectClientTest, self).setUp()
+ self.scenario_name = 'scenrio1'
+ self.base_url = parse.urljoin(
+ self.api_url,
+ 'scenarios/{}/projects'.format(self.scenario_name))
+ self.project_json = {
+ 'trust_indicators': [],
+ 'project': 'test-project',
+ 'scores': [],
+ 'customs': []
+ }
+ self.installer_name = 'installer'
+ self.version_name = 'version'
+ self.project_client = scenarios.ProjectsClient()
+ self.project_string = json.dumps(self.project_json)
+
+
+class ProjectClientCreateTest(ProjectClientTest):
+
+ def setUp(self):
+ super(ProjectClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.project_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.project_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.project_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_json)
+
+
+class ProjectClientDeleteTest(ProjectClientTest):
+
+ def setUp(self):
+ super(ProjectClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.project_client.delete(
+ self.scenario_name, self.installer_name,
+ self.version_name, 'def')
+ kall = self.delete_mock.call_args
+ args, kwargs = kall
+ self.assert_url(
+ args[0],
+ self.base_url + '?installer=installer&version=version')
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.project_client.delete(
+ self.scenario_name, self.installer_name,
+ self.version_name, 'def')
+
+
+class ProjectClientUpdateTest(ProjectClientTest):
+
+ def setUp(self):
+ super(ProjectClientUpdateTest, self).setUp()
+
+ def test_update_success(self):
+ self.put_mock.return_value = fakes.FakeResponse()
+ self.project_client.update(
+ self.scenario_name,
+ self.installer_name,
+ self.version_name,
+ self.project_json)
+ kall = self.put_mock.call_args
+ args, kwargs = kall
+ self.assert_url(
+ args[0],
+ self.base_url + '?installer=installer&version=version')
+
+ def test_update_failure(self):
+ with testtools.ExpectedException(Exception, 'Update failed: Error'):
+ self.put_mock.return_value = utils.FAKE_FAILURE
+ self.project_client.update(
+ self.scenario_name,
+ self.installer_name,
+ self.version_name,
+ self.project_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_scenario_score_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_score_client.py
new file mode 100644
index 0000000..beebd47
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_score_client.py
@@ -0,0 +1,53 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import scenarios
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+
+
+class ScoreClientTest(utils.TestCommand):
+ def setUp(self):
+ super(ScoreClientTest, self).setUp()
+ self.scenario_name = 'scenrio1'
+ self.base_url = parse.urljoin(
+ self.api_url,
+ 'scenarios/{}/scores'.format(self.scenario_name))
+ self.score_json = {
+ 'score': 'test_score1',
+ 'date': '2018/01/2'
+ }
+ self.installer_name = 'installer'
+ self.version_name = 'version'
+ self.project_name = 'project'
+ self.score_client = scenarios.ScoresClient()
+ self.score_string = json.dumps(self.score_json)
+
+
+class ScoreClientCreateTest(ScoreClientTest):
+
+ def setUp(self):
+ super(ScoreClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.score_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.score_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.score_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.score_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.score_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_scenario_trust_indicator_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_trust_indicator_client.py
new file mode 100644
index 0000000..e44e2d2
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_trust_indicator_client.py
@@ -0,0 +1,53 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import scenarios
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+
+
+class TrustIndicatorClientTest(utils.TestCommand):
+ def setUp(self):
+ super(TrustIndicatorClientTest, self).setUp()
+ self.scenario_name = 'scenrio1'
+ self.base_url = parse.urljoin(
+ self.api_url,
+ 'scenarios/{}/trust_indicators'.format(self.scenario_name))
+ self.trust_indicator_json = {
+ 'status': 'test_status',
+ 'date': '2018/01/2'
+ }
+ self.installer_name = 'installer'
+ self.version_name = 'version'
+ self.project_name = 'project'
+ self.trust_indicator_client = scenarios.TrustIndicatorsClient()
+ self.trust_indicator_string = json.dumps(self.trust_indicator_json)
+
+
+class TrustIndicatorClientCreateTest(TrustIndicatorClientTest):
+
+ def setUp(self):
+ super(TrustIndicatorClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.trust_indicator_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.trust_indicator_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.trust_indicator_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.trust_indicator_client.create(
+ self.scenario_name, self.installer_name,
+ self.version_name, self.project_name,
+ self.trust_indicator_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_scenario_version_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_version_client.py
new file mode 100644
index 0000000..1ae2409
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_scenario_version_client.py
@@ -0,0 +1,96 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import scenarios
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class VersionClientTest(utils.TestCommand):
+ def setUp(self):
+ super(VersionClientTest, self).setUp()
+ self.scenario_name = 'scenrio1'
+ self.base_url = parse.urljoin(
+ self.api_url,
+ 'scenarios/{}/versions'.format(self.scenario_name))
+ self.version_json = {
+ 'projects': [],
+ 'version': 'test-version',
+ 'owner': 'test_owner'
+ }
+ self.installer_name = 'installer'
+ self.version_client = scenarios.VersionsClient()
+ self.version_string = json.dumps(self.version_json)
+
+
+class VersionClientCreateTest(VersionClientTest):
+
+ def setUp(self):
+ super(VersionClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.version_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.version_client.create(
+ self.scenario_name, self.installer_name, self.version_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.version_client.create(
+ self.scenario_name, self.installer_name, self.version_json)
+
+
+class VersionClientDeleteTest(VersionClientTest):
+
+ def setUp(self):
+ super(VersionClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.version_client.delete(
+ self.scenario_name, self.installer_name, 'def')
+ kall = self.delete_mock.call_args
+ args, kwargs = kall
+ self.assert_url(
+ args[0],
+ self.base_url + '?installer=installer')
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.version_client.delete(
+ self.scenario_name, self.installer_name, 'def')
+
+
+class VersionClientUpdateTest(VersionClientTest):
+
+ def setUp(self):
+ super(VersionClientUpdateTest, self).setUp()
+
+ def test_update_success(self):
+ self.put_mock.return_value = fakes.FakeResponse()
+ self.version_client.update(
+ self.scenario_name,
+ self.installer_name,
+ self.version_json)
+ self.put_mock.assert_called_once_with(
+ self.base_url + '?installer=installer',
+ data=self.version_string,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_update_failure(self):
+ with testtools.ExpectedException(Exception, 'Update failed: Error'):
+ self.put_mock.return_value = utils.FAKE_FAILURE
+ self.version_client.update(
+ self.scenario_name,
+ self.installer_name,
+ self.version_json)
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_testcase_client.py b/testapi/testapi-client/testapiclient/tests/unit/test_testcase_client.py
new file mode 100644
index 0000000..d80ae27
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_testcase_client.py
@@ -0,0 +1,118 @@
+import json
+
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.client import testcases
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class TestcaseClientTest(utils.TestCommand):
+ def setUp(self):
+ super(TestcaseClientTest, self).setUp()
+ self.base_url = parse.urljoin(self.api_url, 'projects/{}/cases')
+ self.project_name = 'functest'
+ self.testcase_json = {
+ 'run': '',
+ 'name': 'test-case',
+ 'ci_loop': '',
+ 'tags': '',
+ 'url': '',
+ 'blocking': '',
+ 'domains': '',
+ 'dependencies': '',
+ 'version': '',
+ 'criteria': '',
+ 'tier': '',
+ 'trust': '',
+ 'catalog_description': '',
+ 'description': ''
+ }
+ self.testcase_client = testcases.TestcasesClient()
+ self.testcase_string = json.dumps(self.testcase_json)
+
+
+class TestcaseClientGetTest(TestcaseClientTest):
+
+ def setUp(self):
+ super(TestcaseClientGetTest, self).setUp()
+ self.testcases_rsp = {'testcases': [self.testcase_json]}
+
+ def test_get(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.testcases_rsp)
+ self.testcase_client.get(self.project_name)
+ self.get_mock.assert_called_once_with(
+ self.base_url.format(self.project_name),
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_one(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.testcase_json)
+ self.testcase_client.get_one(self.project_name, 'def')
+ self.get_mock.assert_called_once_with(
+ self.base_url.format(self.project_name) + '/def',
+ headers=clientmanager.ClientManager.headers)
+
+
+class TestcaseClientCreateTest(TestcaseClientTest):
+
+ def setUp(self):
+ super(TestcaseClientCreateTest, self).setUp()
+ self.succ_rsp = {
+ 'href': '{}/{}'.format(
+ self.base_url, self.testcase_json.get('name'))
+ }
+
+ def test_create_success(self):
+ self.post_mock.return_value = fakes.FakeResponse(
+ data=self.succ_rsp)
+ self.testcase_client.create(self.project_name, self.testcase_json)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ self.testcase_client.create(self.project_name, self.testcase_json)
+
+
+class TestcaseClientDeleteTest(TestcaseClientTest):
+
+ def setUp(self):
+ super(TestcaseClientDeleteTest, self).setUp()
+
+ def test_delete_success(self):
+ self.delete_mock.return_value = fakes.FakeResponse()
+ self.testcase_client.delete(self.project_name, 'def')
+ self.delete_mock.assert_called_once_with(
+ self.base_url.format(self.project_name) + '/def',
+ data=None,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_delete_failure(self):
+ with testtools.ExpectedException(Exception, 'Delete failed: Error'):
+ self.delete_mock.return_value = utils.FAKE_FAILURE
+ self.testcase_client.delete(self.project_name, 'def')
+
+
+class TestcaseClientUpdateTest(TestcaseClientTest):
+
+ def setUp(self):
+ super(TestcaseClientUpdateTest, self).setUp()
+
+ def test_update_success(self):
+ self.put_mock.return_value = fakes.FakeResponse()
+ self.testcase_client.update(
+ self.project_name, 'def', self.testcase_json)
+ self.put_mock.assert_called_once_with(
+ self.base_url.format(self.project_name) + '/def',
+ data=self.testcase_string,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_update_failure(self):
+ with testtools.ExpectedException(Exception, 'Update failed: Error'):
+ self.put_mock.return_value = utils.FAKE_FAILURE
+ self.testcase_client.update(
+ self.project_name, 'def', self.testcase_json)