Skip to content

Commit e9db0d4

Browse files
authored
Do not use hard-coded url in tests (#405)
1 parent fdd2e0a commit e9db0d4

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

tests/unit/actions/test_steps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77

88
from jbi.actions import default
9+
from jbi.environment import get_settings
910
from jbi.models import ActionContext
1011
from jbi.services.jira import JiraCreateError
1112
from tests.fixtures.factories import comment_factory
@@ -55,7 +56,7 @@ def test_created_public(
5556
)
5657

5758
mocked_bugzilla.update_bug.assert_called_once_with(
58-
654321, see_also={"add": ["https://mozit-test.atlassian.net/browse/k"]}
59+
654321, see_also={"add": [f"{get_settings().jira_base_url}browse/k"]}
5960
)
6061

6162

tests/unit/test_router.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from fastapi.testclient import TestClient
66

77
from jbi.app import app
8+
from jbi.environment import get_settings
89
from jbi.models import BugzillaWebhookRequest
910

1011

@@ -13,7 +14,7 @@ def test_read_root(anon_client):
1314
resp = anon_client.get("/")
1415
infos = resp.json()
1516

16-
assert "atlassian.net" in infos["configuration"]["jira_base_url"]
17+
assert get_settings().jira_base_url in infos["configuration"]["jira_base_url"]
1718

1819

1920
def test_whiteboard_tags(anon_client):
@@ -72,7 +73,7 @@ def test_webhook_is_200_if_action_succeeds(
7273
{
7374
"changes": {
7475
"see_also": {
75-
"added": "https://mozilla.atlassian.net/browse/JBI-1922",
76+
"added": f"{get_settings().jira_base_url}browse/JBI-1922",
7677
"removed": "",
7778
}
7879
},
@@ -85,7 +86,7 @@ def test_webhook_is_200_if_action_succeeds(
8586
}
8687
mocked_jira.create_or_update_issue_remote_links.return_value = {
8788
"id": 18936,
88-
"self": "https://mozilla.atlassian.net/rest/api/2/issue/JBI-1922/remotelink/18936",
89+
"self": f"{get_settings().jira_base_url}rest/api/2/issue/JBI-1922/remotelink/18936",
8990
}
9091

9192
with TestClient(app) as anon_client:

tests/unit/test_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010

1111
from jbi import Operation
12-
from jbi.environment import Settings
12+
from jbi.environment import Settings, get_settings
1313
from jbi.errors import IgnoreInvalidRequestError
1414
from jbi.models import Actions, BugzillaBug, BugzillaWebhookRequest
1515
from jbi.runner import execute_action
@@ -25,7 +25,7 @@ def test_bugzilla_object_is_always_fetched(
2525
# See https://github.com/mozilla/jira-bugzilla-integration/issues/292
2626
fetched_bug = bug_factory(
2727
id=webhook_create_example.bug.id,
28-
see_also=["https://mozilla.atlassian.net/browse/JBI-234"],
28+
see_also=[f"{get_settings().jira_base_url}browse/JBI-234"],
2929
)
3030
mocked_bugzilla.get_bug.return_value = fetched_bug
3131

0 commit comments

Comments
 (0)