diff --git a/bin/do_epic/e2e/settings.py b/bin/do_epic/e2e/settings.py index a4f730ab..3373bc67 100644 --- a/bin/do_epic/e2e/settings.py +++ b/bin/do_epic/e2e/settings.py @@ -31,15 +31,15 @@ def read(env: typing.Mapping[str, str]) -> Sandbox | Failure: values = {name: env.get(name, "").strip() for name in MEANING} url, project = values[JIRA_URL], values[PROJECT] env_file = pathlib.Path(values[ENV_FILE]) if values[ENV_FILE] else None - absolute = env_file is not None and env_file.is_absolute() + usable = env_file if env_file is not None and env_file.is_absolute() else None faults = [ *(f"{name} is missing: set it to {meaning}" for name, meaning in MEANING.items() if not values[name]), *([f"{JIRA_URL} is {url!r}, not an https address without a path"] if url and not re.fullmatch(SITE, url) else []), *([f"{PROJECT} is {project!r}, not a project key such as SBX"] if project and not re.fullmatch(PROJECT_KEY, project) else []), - *([f"{ENV_FILE} is {values[ENV_FILE]!r}, not an absolute path"] if env_file is not None and not absolute else []), + *([f"{ENV_FILE} is {values[ENV_FILE]!r}, not an absolute path"] if env_file is not None and usable is None else []), ] - if env_file is not None and absolute: - login = basic_auth(env_file) + if usable is not None: + login = basic_auth(usable) if isinstance(login, Failure): faults.append(login.reason) if faults: diff --git a/bin/do_epic/e2e/test_sandbox.py b/bin/do_epic/e2e/test_sandbox.py index 0616b5ec..c341837f 100644 --- a/bin/do_epic/e2e/test_sandbox.py +++ b/bin/do_epic/e2e/test_sandbox.py @@ -78,6 +78,14 @@ class EpicMadeTest(unittest.TestCase): self.assertIn("holds no issues", str(left.exception)) self.assertEqual(jira.requests[1:], [("POST", "search/jql"), ("DELETE", "issue/SBX-1?deleteSubtasks=true")]) + def test_deletes_the_epic_all_the_same_and_gives_the_reason_when_the_search_for_its_issues_is_refused(self) -> None: + jira = JiraStub(refuses="search/jql") + with self.assertRaises(Leftover) as left: + with epic_made(self.sandbox, "An epic", jira, lambda markdown: {"type": "doc"}): + pass + self.assertIn("POST https://acme.atlassian.net/rest/api/3/search/jql answered 403", str(left.exception)) + self.assertEqual(jira.requests[1:], [("POST", "search/jql"), ("DELETE", "issue/SBX-1?deleteSubtasks=true")]) + def test_yields_a_failure_and_deletes_nothing_when_the_epic_cannot_be_made(self) -> None: jira = JiraStub(refuses="/issue") with epic_made(self.sandbox, "An epic", jira, lambda markdown: {"type": "doc"}) as key: