summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient/client/results.py
blob: 7d9ad0e8762493074cf36ca76f857d762cdba496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)))