stub_client.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from fixtures.integrations.stub_service import StubService
  2. from sentry.shared_integrations.exceptions import ApiError
  3. class StubJiraApiClient(StubService):
  4. service_name = "jira"
  5. def get_create_meta_for_project(self, project):
  6. response = self._get_stub_data("createmeta_response.json")
  7. if project == "10001":
  8. response["projects"][0]["id"] = "10001"
  9. return response["projects"][0]
  10. def get_issue_fields(self, project_id, issue_type_id):
  11. return self._get_stub_data("issue_fields_response.json")
  12. def get_issue_types(self, project_id):
  13. return self._get_stub_data("issue_types_response.json")
  14. def get_priorities(self, project_id):
  15. return self._get_stub_data("priorities_response.json")
  16. def get_versions(self, project_id):
  17. return self._get_stub_data("versions_response.json")
  18. def get_projects_list(self, cached=True):
  19. return self._get_stub_data("project_list_response.json")
  20. def get_issue(self, issue_key):
  21. return self._get_stub_data("get_issue_response.json")
  22. def create_comment(self, issue_id, comment):
  23. return comment
  24. def update_comment(self, issue_key, comment_id, comment):
  25. return comment
  26. def create_issue(self, raw_form_data):
  27. return {"key": "APP-123"}
  28. def get_transitions(self, issue_key):
  29. return self._get_stub_data("transition_response.json")["transitions"]
  30. def transition_issue(self, issue_key, transition_id):
  31. pass
  32. def user_id_field(self):
  33. return "accountId"
  34. def get_user(self, user_id):
  35. user = self._get_stub_data("user.json")
  36. if user["accountId"] == user_id:
  37. return user
  38. raise ApiError("no user found")
  39. def get_valid_statuses(self):
  40. return self._get_stub_data("status_response.json")
  41. def search_users_for_project(self, project, username):
  42. return [self._get_stub_data("user.json")]