From dea82c2e623212f08840060a55d0867754b9dbf2 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 3 Oct 2023 17:23:27 -0400 Subject: [PATCH 1/6] fix: create jira issues with fewer fields These fields aren't available in the 2U Jira instance any longer, so don't try to set them. --- openedx_webhooks/tasks/pr_tracking.py | 59 ++++++--------------------- openedx_webhooks/utils.py | 12 ------ tests/test_pull_request_opened.py | 12 +++++- 3 files changed, 23 insertions(+), 60 deletions(-) diff --git a/openedx_webhooks/tasks/pr_tracking.py b/openedx_webhooks/tasks/pr_tracking.py index 76682327..f3d3a486 100644 --- a/openedx_webhooks/tasks/pr_tracking.py +++ b/openedx_webhooks/tasks/pr_tracking.py @@ -9,7 +9,7 @@ import dataclasses import itertools from dataclasses import dataclass, field -from typing import Dict, List, Optional, Set, Tuple, cast +from typing import Dict, List, Optional, Set, cast from openedx_webhooks.auth import get_github_session, get_jira_session from openedx_webhooks.bot_comments import ( @@ -41,7 +41,6 @@ from openedx_webhooks.info import ( get_blended_project_id, get_bot_comments, - get_people_file, is_bot_pull_request, is_draft_pull_request, is_internal_pull_request, @@ -61,7 +60,6 @@ ) from openedx_webhooks.types import GhProject, JiraId, PrDict, PrId from openedx_webhooks.utils import ( - get_jira_custom_fields, log_check_response, retry_get, sentry_extra_context, @@ -233,7 +231,14 @@ def desired_support_state(pr: PrDict) -> PrDesiredInfo: raise Exception(f"A crash label was applied by {user}") desired.jira_title = pr["title"] - desired.jira_description = pr["body"] or "" + print(pr) + desired.jira_description = ( + "(From {url} by {user_url})\n------\n\n{body}" + ).format( + url=pr["html_url"], + body=(pr["body"] or ""), + user_url=pr["user"]["html_url"], + ) blended_id = get_blended_project_id(pr) if blended_id is not None: @@ -400,16 +405,13 @@ def _make_jira_issue(self, jira_nick) -> None: """ Make a Jira issue in a particular Jira server. """ - user_name, institution = get_name_and_institution_for_pr(self.pr) issue_data = self.actions.create_jira_issue( jira_nick=jira_nick, - pr_url=self.pr["html_url"], - project="TODOXXX", # TODO: get the real project + project=project, + issuetype=issuetype, summary=self.desired.jira_title, description=self.desired.jira_description, labels=list(self.desired.jira_labels), - user_name=user_name, - institution=institution, ) jira_id = JiraId(jira_nick, issue_data["key"]) @@ -513,33 +515,6 @@ def _add_bot_comments(self): assert needed_comments == set(), f"Couldn't make comments: {needed_comments}" -def get_name_and_institution_for_pr(pr: PrDict) -> Tuple[str, Optional[str]]: - """ - Get the author name and institution for a pull request. - - The returned name will always be a string. The institution might be None. - - Returns: - name, institution - """ - user = pr["user"]["login"] - people = get_people_file() - - user_name = None - if user in people: - user_name = people[user].get("name", "") - if not user_name: - resp = retry_get(get_github_session(), pr["user"]["url"]) - if resp.ok: - user_name = resp.json().get("name", user) - else: - user_name = user - - institution = people.get(user, {}).get("institution", None) - - return user_name, institution - - class DryRunFixingActions: """ Implementation of actions for dry runs. @@ -588,13 +563,10 @@ def initial_state(self, *, current: Dict, desired: Dict) -> None: def create_jira_issue( self, *, jira_nick: str, - pr_url: str, project: str, summary: Optional[str], description: Optional[str], labels: List[str], - user_name: Optional[str], - institution: Optional[str], ) -> Dict: """ Create a new Jira issue for a pull request. @@ -602,26 +574,19 @@ def create_jira_issue( Returns the JSON describing the issue. """ - custom_fields = get_jira_custom_fields(jira_nick) new_issue = { "fields": { "project": { "key": project, }, "issuetype": { - "name": "Pull Request Review", + "name": "Task", }, "summary": summary, "description": description, "labels": labels, - "customfield_10904": pr_url, # "URL" is ambiguous, use the internal name. - custom_fields["PR Number"]: self.prid.number, - custom_fields["Repo"]: self.prid.full_name, - custom_fields["Contributor Name"]: user_name, } } - if institution: - new_issue["fields"][custom_fields["Customer"]] = [institution] sentry_extra_context({"new_issue": new_issue}) logger.info(f"Creating new JIRA issue for PR {self.prid}...") diff --git a/openedx_webhooks/utils.py b/openedx_webhooks/utils.py index c66b9ebd..70d7a646 100644 --- a/openedx_webhooks/utils.py +++ b/openedx_webhooks/utils.py @@ -304,18 +304,6 @@ def sentry_extra_context(data_dict): scope.set_extra(key, value) -@memoize_timed(minutes=30) -def get_jira_custom_fields(jira_nick: str): - """ - Return a name-to-id mapping for the custom fields on JIRA. - """ - session = get_jira_session(jira_nick) - field_resp = session.get("/rest/api/2/field") - field_resp.raise_for_status() - fields = field_resp.json() - return {f["name"]: f["id"] for f in fields if f["custom"]} - - def get_jira_issue(jira_nick: str, key: str, missing_ok: bool = False) -> Optional[JiraDict]: """ Get the dictionary for a Jira issue, from its key. diff --git a/tests/test_pull_request_opened.py b/tests/test_pull_request_opened.py index 46798243..1dad852f 100644 --- a/tests/test_pull_request_opened.py +++ b/tests/test_pull_request_opened.py @@ -1,5 +1,7 @@ """Tests of tasks/github.py:pull_request_changed for opening pull requests.""" +import textwrap + import pytest from openedx_webhooks.bot_comments import ( @@ -343,7 +345,7 @@ def test_crash_label(fake_github): def test_jira_labelling(fake_github, fake_jira, fake_jira2): # A PR with a "jira:" label makes a Jira issue. - pr = fake_github.make_pull_request("openedx", user="nedbat", title="Ned's PR") + pr = fake_github.make_pull_request("openedx", user="nedbat", number=99, title="Ned's PR", body="Line1\nLine2\n") pr.set_labels(["jira:test1"]) assert len(pr.list_comments()) == 0 @@ -360,6 +362,14 @@ def test_jira_labelling(fake_github, fake_jira, fake_jira2): assert "in the private Test1 Jira" in body jira_issue = fake_jira.issues[jira_id.key] assert jira_issue.summary == "Ned's PR" + assert jira_issue.description == textwrap.dedent("""\ + (From https://github.com/openedx/a-repo/pull/99 by https://github.com/nedbat) + ------ + + Line1 + Line2 + """ + ) # Processing the pull request again won't make another issue. result = pull_request_changed(pr.as_json()) From f5273cbd5e2e7ade833d57ceb1419009a5714211 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 17 Oct 2023 17:25:50 -0400 Subject: [PATCH 2/6] feat: mapping repos to Jira details --- openedx_webhooks/info.py | 64 +++++++++++++++++-- openedx_webhooks/tasks/pr_tracking.py | 6 +- openedx_webhooks/types.py | 6 +- tests/conftest.py | 2 +- .../anotherorg/dot-github/jira-mapping.yaml | 4 ++ .../openedx-webhooks-data/test-jira-info.yaml | 12 ++-- .../test1/dot-github/jira-mapping.yaml | 13 ++++ tests/test_info.py | 21 +++++- tests/test_pull_request_opened.py | 4 +- 9 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 tests/repo_data/anotherorg/dot-github/jira-mapping.yaml create mode 100644 tests/repo_data/test1/dot-github/jira-mapping.yaml diff --git a/openedx_webhooks/info.py b/openedx_webhooks/info.py index 2893a530..be0cd8e3 100644 --- a/openedx_webhooks/info.py +++ b/openedx_webhooks/info.py @@ -2,6 +2,7 @@ Get information about people, repos, orgs, pull requests, etc. """ import csv +import fnmatch import logging import re from typing import Dict, Iterable, Optional @@ -61,18 +62,34 @@ def _read_github_file(repo_fullname: str, file_path: str, not_there: Optional[st `file_path`: the path to the file within the repo. `not_there`: if provided, text to return if the file (or repo) doesn't exist. + Returns: + The text of the file, or `not_there` if provided. + """ + return _read_github_url(_github_file_url(repo_fullname, file_path), not_there) + +def _read_github_url(url: str, not_there: Optional[str] = None) -> str: + """ + Read the content of a GitHub URL. + + `not_there` is for handling missing files. All other errors trying to + access the file are raised as exceptions. + + Arguments: + `url`: the complete GitHub URL to read. + `not_there`: if provided, text to return if the file (or repo) doesn't exist. + Returns: The text of the file, or `not_there` if provided. """ github = get_github_session() - data_file_url = _github_file_url(repo_fullname, file_path) - logger.debug(f"Grabbing data file from: {data_file_url}") - resp = github.get(data_file_url) + logger.debug(f"Grabbing data file from: {url}") + resp = github.get(url) if resp.status_code == 404 and not_there is not None: return not_there resp.raise_for_status() return resp.text + @memoize_timed(minutes=15) def get_people_file(): """ @@ -125,7 +142,10 @@ def get_orgs_file(): @memoize_timed(minutes=30) -def get_jira_info(): +def get_jira_info() -> dict[str, JiraServer]: + """ + Get the dict mapping Jira nicknames to JiraServer objects. + """ jira_info = {} for key, info in _read_yaml_data_file(settings.JIRA_INFO_FILE).items(): jira_info[key.lower()] = JiraServer(**info) @@ -133,6 +153,9 @@ def get_jira_info(): def get_jira_server_info(jira_nick: str) -> JiraServer: + """ + Given a Jira nickname, get the JiraServer info about it. + """ jira_info = get_jira_info() jira_server = jira_info[jira_nick.lower()] return jira_server @@ -300,3 +323,36 @@ def projects_for_pr(pull_request: PrDict) -> Iterable[GhProject]: org, number = spec.strip().split(":") gh_projects.append((org, int(number))) return gh_projects + + +def jira_details_for_pr(jira_nick: str, pr: PrDict) -> tuple[str, str]: + """ + Determine what Jira project and issuetype should be used. + + The jira mapping file looks like this:: + + # Mapping from repo to Jira. + defaults: + type: Task + repos: + - name: openedx/edx-platform + project: ARCHBOM + type: Task + - name: nedbat/* + project: ARCHBOM + - name: "*" + project: CATCHALL + type: OtherType + + """ + + jira_info = get_jira_server_info(jira_nick) + mapping = yaml.safe_load(_read_github_url(jira_info.mapping)) + repo_name = pr["base"]["repo"]["full_name"] + details = mapping.get("defaults", {}) + for repo_info in mapping.get("repos", []): + if fnmatch.fnmatch(repo_name, repo_info["name"]): + details.update(repo_info) + break + + return details["project"], details["type"] diff --git a/openedx_webhooks/tasks/pr_tracking.py b/openedx_webhooks/tasks/pr_tracking.py index f3d3a486..d42e5efa 100644 --- a/openedx_webhooks/tasks/pr_tracking.py +++ b/openedx_webhooks/tasks/pr_tracking.py @@ -45,6 +45,7 @@ is_draft_pull_request, is_internal_pull_request, is_private_repo_no_cla_pull_request, + jira_details_for_pr, projects_for_pr, pull_request_has_cla, repo_refuses_contributions, @@ -61,7 +62,6 @@ from openedx_webhooks.types import GhProject, JiraId, PrDict, PrId from openedx_webhooks.utils import ( log_check_response, - retry_get, sentry_extra_context, text_summary, ) @@ -405,6 +405,7 @@ def _make_jira_issue(self, jira_nick) -> None: """ Make a Jira issue in a particular Jira server. """ + project, issuetype = jira_details_for_pr(jira_nick, self.pr) issue_data = self.actions.create_jira_issue( jira_nick=jira_nick, project=project, @@ -564,6 +565,7 @@ def create_jira_issue( self, *, jira_nick: str, project: str, + issuetype: str, summary: Optional[str], description: Optional[str], labels: List[str], @@ -580,7 +582,7 @@ def create_jira_issue( "key": project, }, "issuetype": { - "name": "Task", + "name": issuetype, }, "summary": summary, "description": description, diff --git a/openedx_webhooks/types.py b/openedx_webhooks/types.py index 15d2d64d..28b2ec63 100644 --- a/openedx_webhooks/types.py +++ b/openedx_webhooks/types.py @@ -49,10 +49,10 @@ class JiraServer: # A description of the server, suitable for the bot to comment, # "I created an issue in {{ description }}." - description: str = "a Jira server" + description: str - mapping: str | None = None - project: str | None = None + # The URL to get jira-mapping.yaml from. + mapping: str @dataclasses.dataclass(frozen=True) diff --git a/tests/conftest.py b/tests/conftest.py index 9c47c3fd..5d6773d5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -102,7 +102,7 @@ def fake_jira(requests_mocker, fake_repo_data): @pytest.fixture def fake_jira2(requests_mocker, fake_repo_data): """A FakeJira for the second server configured in our jira-info.yaml.""" - the_fake_jira = FakeJira("https://anothertest.atlassian.net") + the_fake_jira = FakeJira("https://anotherorg.atlassian.net") the_fake_jira.install_mocks(requests_mocker) return the_fake_jira diff --git a/tests/repo_data/anotherorg/dot-github/jira-mapping.yaml b/tests/repo_data/anotherorg/dot-github/jira-mapping.yaml new file mode 100644 index 00000000..a83ab06f --- /dev/null +++ b/tests/repo_data/anotherorg/dot-github/jira-mapping.yaml @@ -0,0 +1,4 @@ +# Mapping from repo to Jira. +defaults: + project: ONEBUCKET + type: Task diff --git a/tests/repo_data/openedx/openedx-webhooks-data/test-jira-info.yaml b/tests/repo_data/openedx/openedx-webhooks-data/test-jira-info.yaml index 04763772..ad6fc5e5 100644 --- a/tests/repo_data/openedx/openedx-webhooks-data/test-jira-info.yaml +++ b/tests/repo_data/openedx/openedx-webhooks-data/test-jira-info.yaml @@ -4,11 +4,11 @@ Test1: server: https://test.atlassian.net email: jira-user@test1.com token: asdasdasdasdasd - mapping: https://github.com/test1/.github/jira-mapping.yaml + mapping: https://raw.githubusercontent.com/test1/dot-github/HEAD/jira-mapping.yaml description: the private Test1 Jira -AnotherTest: - server: https://anothertest.atlassian.net - email: jira-user@anothertest.com +AnotherOrg: + server: https://anotherorg.atlassian.net + email: jira-user@anotherorg.com token: xyzzyxyzzy - project: OPEN - description: the Another Test Jira + mapping: https://raw.githubusercontent.com/anotherorg/dot-github/HEAD/jira-mapping.yaml + description: the Another Org Jira diff --git a/tests/repo_data/test1/dot-github/jira-mapping.yaml b/tests/repo_data/test1/dot-github/jira-mapping.yaml new file mode 100644 index 00000000..3ae77fc6 --- /dev/null +++ b/tests/repo_data/test1/dot-github/jira-mapping.yaml @@ -0,0 +1,13 @@ +# Mapping from repo to Jira. +defaults: + type: Task +repos: + - name: openedx/edx-platform + project: ARCHBOM + type: Bug + + - name: nedbat/* + project: NEDBAT + + - name: "*" + project: EVERYTHING diff --git a/tests/test_info.py b/tests/test_info.py index f4042f8e..a9651316 100644 --- a/tests/test_info.py +++ b/tests/test_info.py @@ -10,6 +10,7 @@ get_people_file, is_draft_pull_request, is_internal_pull_request, + jira_details_for_pr, ) @@ -133,4 +134,22 @@ def test_jira_info(): info = get_jira_info() # These are specific items from our test jira-info.yaml file assert info["test1"].server == "https://test.atlassian.net" - assert info["anothertest"].project == "OPEN" + assert ( + info["anotherorg"].mapping == + "https://raw.githubusercontent.com/anotherorg/dot-github/HEAD/jira-mapping.yaml" + ) + + +@pytest.mark.parametrize( + "owner, repo, project, issuetype", + [ + ("openedx", "edx-platform", "ARCHBOM", "Bug"), + ("nedbat", "anything", "NEDBAT", "Task"), + ("another", "something", "EVERYTHING", "Task"), + ] +) +def test_jira_details_for_pr(fake_github, owner, repo, project, issuetype): + pr = fake_github.make_pull_request(owner=owner, repo=repo) + actual_project, actual_issuetype = jira_details_for_pr("test1", pr.as_json()) + assert project == actual_project + assert issuetype == actual_issuetype diff --git a/tests/test_pull_request_opened.py b/tests/test_pull_request_opened.py index 1dad852f..6aba3602 100644 --- a/tests/test_pull_request_opened.py +++ b/tests/test_pull_request_opened.py @@ -401,7 +401,7 @@ def test_jira_labelling_later(fake_github, fake_jira, fake_jira2): assert len(pr_comments) == 1 # You can add a second label for another Jira server. - pr.set_labels(["jira:AnotherTest"]) + pr.set_labels(["jira:AnotherOrg"]) result = pull_request_changed(pr.as_json()) assert len(result.jira_issues) == 2 assert len(result.changed_jira_issues) == 1 @@ -412,6 +412,6 @@ def test_jira_labelling_later(fake_github, fake_jira, fake_jira2): body = pr_comments[-1].body jira_id = result.changed_jira_issues.pop() check_issue_link_in_markdown(body, jira_id) - assert "in the Another Test Jira" in body + assert "in the Another Org Jira" in body jira_issue = fake_jira2.issues[jira_id.key] assert jira_issue.summary == "Yet another PR" From 19f73cbe0c46fac5df4a163ed47025c6157a72c8 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 19 Oct 2023 16:57:18 -0400 Subject: [PATCH 3/6] test: add test of bad jira labelling --- tests/test_pull_request_opened.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_pull_request_opened.py b/tests/test_pull_request_opened.py index 6aba3602..b1f2df0e 100644 --- a/tests/test_pull_request_opened.py +++ b/tests/test_pull_request_opened.py @@ -415,3 +415,14 @@ def test_jira_labelling_later(fake_github, fake_jira, fake_jira2): assert "in the Another Org Jira" in body jira_issue = fake_jira2.issues[jira_id.key] assert jira_issue.summary == "Yet another PR" + +def test_bad_jira_labelling(fake_github, fake_jira, fake_jira2): + # What if the jira: label doesn't match one of our configured servers? + pr = fake_github.make_pull_request("openedx", user="nedbat", title="Ned's PR") + pr.set_labels(["jira:bogus"]) + with pytest.raises(ExceptionGroup) as exc_info: + pull_request_changed(pr.as_json()) + assert len(exc_info.value.exceptions) == 1 + exc = exc_info.value.exceptions[0] + assert isinstance(exc, KeyError) + assert exc.args == ("bogus",) From 5c4564d1aa8ea3fc9a593ab618b0583f01f9e6fb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 19 Oct 2023 16:57:35 -0400 Subject: [PATCH 4/6] docs: describe the manual Jira labelling flow --- docs/details.rst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/details.rst b/docs/details.rst index d5889be0..df9958c5 100644 --- a/docs/details.rst +++ b/docs/details.rst @@ -5,8 +5,8 @@ Here are the details of what the bot does. .. _pr_to_jira: -Making a Jira issue for a pull request --------------------------------------- +When a pull request is opened +----------------------------- The bot gets notifications from GitHub when a pull request is created in the organizations and/or repos where it is configured. It's currently configured @@ -113,3 +113,18 @@ organization. openedx.org/add-to-projects: "openedx:23" The bot never removes pull requests from projects. + + +Making a Jira issue for a pull request +-------------------------------------- + +The bot used to automatically make Jira issues for pull requests, but no longer +does. Now a Jira issue will be created if a specific label is added to the +pull request. + +The bot is configured to know about a small handful of Jira servers, each with +a short "nickname". If you add a label of ``jira:xyz`` to a pull request, the +bot will create a Jira issue in the Jira server with the "xyz" nickname. + +Each Jira server can specify a mapping of repos to other Jira details such as +the Jira project for the issue, and the issue type to create. From 21852f52a9f916e1c627e58aef1e94187c81f4b3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 20 Oct 2023 15:04:32 -0400 Subject: [PATCH 5/6] fix: better exception for failed requests --- openedx_webhooks/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openedx_webhooks/utils.py b/openedx_webhooks/utils.py index 70d7a646..369fc06c 100644 --- a/openedx_webhooks/utils.py +++ b/openedx_webhooks/utils.py @@ -61,6 +61,9 @@ def decorated(*args, **kwargs): return decorated +class RequestFailed(Exception): + pass + def log_check_response(response, raise_for_status=True): """ Logs HTTP request and response at debug level and checks if it succeeded. @@ -77,10 +80,9 @@ def log_check_response(response, raise_for_status=True): if raise_for_status: try: response.raise_for_status() - except Exception: + except Exception as exc: req = response.request - logger.exception(f"HTTP request failed: {req.method} {req.url}. Response body: {response.content}") - raise + raise RequestFailed(f"HTTP request failed: {req.method} {req.url}. Response body: {response.content}") from exc def log_rate_limit(): From 160ccb6327e84d46ad9db3544321cfae6dbff3c4 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 20 Oct 2023 19:02:04 -0400 Subject: [PATCH 6/6] test: remove now-unused custom field stuff from fake_jira --- tests/fake_jira.py | 33 --------------------------------- tests/test_auth.py | 4 ++-- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/tests/fake_jira.py b/tests/fake_jira.py index 6c13618b..7d475ee3 100644 --- a/tests/fake_jira.py +++ b/tests/fake_jira.py @@ -22,11 +22,6 @@ class Issue: key: str status: str issuetype: Optional[str] = None - contributor_name: Optional[str] = None - customer: Optional[str] = None - pr_number: Optional[int] = None - repo: Optional[str] = None - url: Optional[str] = None description: Optional[str] = None summary: Optional[str] = None labels: Set[str] = field(default_factory=set) @@ -41,11 +36,6 @@ def as_json(self) -> Dict: "summary": self.summary or None, "description": self.description or None, "labels": sorted(self.labels), - FakeJira.CONTRIBUTOR_NAME: self.contributor_name or None, - FakeJira.CUSTOMER: self.customer or None, - FakeJira.PR_NUMBER: self.pr_number, - FakeJira.REPO: self.repo or None, - FakeJira.URL: self.url or None, }, } @@ -53,13 +43,6 @@ def as_json(self) -> Dict: class FakeJira(faker.Faker): """A fake implementation of the Jira API, specialized to the OSPR project.""" - # Custom fields for OSPR. The values are arbitrary. - CONTRIBUTOR_NAME = "custom_101" - CUSTOMER = "custom_102" - PR_NUMBER = "custom_103" - REPO = "custom_104" - URL = "customfield_10904" # This one is hard-coded - # Issue states and transitions for OSPR. INITIAL_STATE = "Needs Triage" @@ -92,17 +75,6 @@ def __init__(self, host) -> None: # Map from old keys to new keys for moved issues. self.moves: Dict[str, str] = {} - @faker.route(r"/rest/api/2/field") - def _get_field(self, _match, _request, _context) -> List[Dict]: - # Custom fields particular to the OSPR project. - return [{"id": i, "name": n, "custom": True} for i, n in [ - (self.CONTRIBUTOR_NAME, "Contributor Name"), - (self.CUSTOMER, "Customer"), - (self.PR_NUMBER, "PR Number"), - (self.REPO, "Repo"), - (self.URL, "URL"), - ]] - def make_issue(self, key: Optional[str] = None, project: str = "OSPR", **kwargs) -> Issue: """Make fake issue data.""" if key is None: @@ -153,11 +125,6 @@ def _post_issue(self, _match, request, context): summary=fields.get("summary"), description=fields.get("description"), labels=set(fields.get("labels")), - contributor_name=fields.get(FakeJira.CONTRIBUTOR_NAME), - customer=fields.get(FakeJira.CUSTOMER), - pr_number=fields.get(FakeJira.PR_NUMBER), - repo=fields.get(FakeJira.REPO), - url=fields.get(FakeJira.URL), ) self.make_issue(key, **kwargs) # Response is only some information: diff --git a/tests/test_auth.py b/tests/test_auth.py index 2c4a8498..8544603f 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -15,9 +15,9 @@ def test_get_github_session(fake_github): def test_get_jira_session(fake_jira): session = get_jira_session("test1") - response = session.get("/rest/api/2/field") + response = session.get("/rest/api/2/issue/FOO-99") headers = response.request.headers user_token = "jira-user@test1.com:asdasdasdasdasd" basic_auth = base64.b64encode(user_token.encode()).decode() assert headers["Authorization"] == f"Basic {basic_auth}" - assert response.url == "https://test.atlassian.net/rest/api/2/field" + assert response.url == "https://test.atlassian.net/rest/api/2/issue/FOO-99"