-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathissueClient.py
55 lines (48 loc) · 1.96 KB
/
issueClient.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import requests
from django.urls import reverse
import json
from kernelCI_app.unitTests.utils.client.baseClient import BaseClient
class IssueClient(BaseClient):
def get_issues_list(
self, *, interval_in_days: int | None, culprit_data: dict | None
) -> requests.Response:
path = reverse("issue")
if culprit_data is None:
culprit_data = {}
query = {"intervalInDays": interval_in_days, **culprit_data}
url = self.get_endpoint(path=path, query=query)
return requests.get(url)
def get_issues_details(
self, *, issue_id: str, issue_version: int | None
) -> requests.Response:
path = reverse("issueDetails", kwargs={"issue_id": issue_id})
query = {"version": issue_version}
url = self.get_endpoint(path=path, query=query)
return requests.get(url)
def get_issues_extra(
self, *, issues_list: list[tuple[str, int | None]]
) -> requests.Response:
path = reverse("issueExtraDetails")
url = self.get_endpoint(path=path)
return requests.post(url=url, data=json.dumps({"issues": issues_list}))
def _get_issues_resources(
self, *, viewname: str, issue_id: str, issue_version: int | None
) -> requests.Response:
path = reverse(viewname, kwargs={"issue_id": issue_id})
query = {"version": issue_version}
url = self.get_endpoint(path=path, query=query)
return requests.get(url)
def get_issue_tests(
self, *, issue_id: str, issue_version: int | None
) -> requests.Response:
return self._get_issues_resources(
viewname="issueDetailsTests", issue_id=issue_id, issue_version=issue_version
)
def get_issue_builds(
self, *, issue_id: str, issue_version: int | None
) -> requests.Response:
return self._get_issues_resources(
viewname="issueDetailsBuilds",
issue_id=issue_id,
issue_version=issue_version,
)