Skip to content

Commit 8a56903

Browse files
committed
[tests:releaser] Avoid real HTTP requests in tests
1 parent 68dbf37 commit 8a56903

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

openwisp_utils/releaser/tests/conftest.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import subprocess
23
from datetime import datetime
34
from pathlib import Path
@@ -70,7 +71,6 @@ def mock_all(mocker):
7071
stdout="main", check_returncode=True
7172
),
7273
}
73-
7474
default_mock = MagicMock(stdout="", stderr="", check_returncode=True)
7575

7676
def subprocess_side_effect(command, *args, **kwargs):
@@ -92,6 +92,15 @@ def subprocess_side_effect(command, *args, **kwargs):
9292
"openwisp_utils.releaser.version.questionary.select", new=mock_q_select
9393
)
9494

95+
# Mock OPENAI_CHATGPT_TOKEN to None to skip AI summary by default
96+
original_environ_get = os.environ.get
97+
98+
def mock_environ_get(key, default=None):
99+
if key == "OPENAI_CHATGPT_TOKEN":
100+
return None
101+
return original_environ_get(key, default)
102+
103+
mocker.patch("os.environ.get", side_effect=mock_environ_get)
95104
mocks = {
96105
"subprocess": mocker.patch(
97106
"openwisp_utils.releaser.release.subprocess.run",
@@ -149,5 +158,4 @@ def subprocess_side_effect(command, *args, **kwargs):
149158
}
150159
mocks["check_prerequisites"].return_value = (mock_config, mock_gh_instance)
151160
mocks["load_config"].return_value = mock_config
152-
153161
return mocks

0 commit comments

Comments
 (0)