stub_client.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from fixtures.integrations 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_projects_list(self):
  11. return self._get_stub_data("project_list_response.json")
  12. def get_issue(self, issue_key):
  13. return self._get_stub_data("get_issue_response.json")
  14. def create_comment(self, issue_id, comment):
  15. return comment
  16. def update_comment(self, issue_key, comment_id, comment):
  17. return comment
  18. def create_issue(self, raw_form_data):
  19. return {"key": "APP-123"}
  20. def get_transitions(self, issue_key):
  21. return self._get_stub_data("transition_response.json")["transitions"]
  22. def transition_issue(self, issue_key, transition_id):
  23. pass
  24. def user_id_field(self):
  25. return "accountId"
  26. def get_user(self, user_id):
  27. user = self._get_stub_data("user.json")
  28. if user["accountId"] == user_id:
  29. return user
  30. raise ApiError("no user found")
  31. def get_valid_statuses(self):
  32. return self._get_stub_data("status_response.json")
  33. def search_users_for_project(self, project, username):
  34. return [self._get_stub_data("user.json")]