Skip to content

Commit 6dbe31d

Browse files
committed
Move http module in imports and mock patches
1 parent cf62121 commit 6dbe31d

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

tests/protocols/http/core/test_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
class GvmHttpApiTestCase(unittest.TestCase):
1212
# pylint: disable=protected-access
1313

14-
@patch("gvm.http.core.connector.HttpApiConnector")
14+
@patch("gvm.protocols.http.core.connector.HttpApiConnector")
1515
def test_basic_init(self, connector_mock: MagicMock):
1616
api = GvmHttpApi(connector_mock)
1717
self.assertEqual(connector_mock, api._connector)
1818

19-
@patch("gvm.http.core.connector.HttpApiConnector")
19+
@patch("gvm.protocols.http.core.connector.HttpApiConnector")
2020
def test_init_with_key(self, connector_mock: MagicMock):
2121
api = GvmHttpApi(connector_mock, api_key="my-api-key")
2222
self.assertEqual(connector_mock, api._connector)

tests/protocols/http/core/test_connector.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from httpx import HTTPError
1313

1414
from gvm.protocols.http.core.connector import HttpApiConnector
15-
from gvm.protocols.http.core import ContentType
15+
from gvm.protocols.http.core.headers import ContentType
1616

1717
TEST_JSON_HEADERS = {
1818
"content-type": "application/json;charset=utf-8",
@@ -115,7 +115,7 @@ def test_new_session(self):
115115
new_client = HttpApiConnector._new_client()
116116
self.assertIsInstance(new_client, httpx.Client)
117117

118-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
118+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
119119
def test_basic_init(self, new_client_mock: MagicMock):
120120
mock_client = new_client_mock.return_value = new_mock_client()
121121

@@ -125,7 +125,7 @@ def test_basic_init(self, new_client_mock: MagicMock):
125125
new_client_mock.assert_called_once_with(None, None)
126126
self.assertEqual({}, mock_client.headers)
127127

128-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
128+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
129129
def test_https_init(self, new_client_mock: MagicMock):
130130
mock_client = new_client_mock.return_value = new_mock_client()
131131

@@ -139,7 +139,7 @@ def test_https_init(self, new_client_mock: MagicMock):
139139
new_client_mock.assert_called_once_with("foo.crt", "bar.key")
140140
self.assertEqual({}, mock_client.headers)
141141

142-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
142+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
143143
def test_update_headers(self, new_client_mock: MagicMock):
144144
mock_client = new_client_mock.return_value = new_mock_client()
145145

@@ -151,7 +151,7 @@ def test_update_headers(self, new_client_mock: MagicMock):
151151

152152
self.assertEqual({"x-foo": "bar", "x-baz": "123"}, mock_client.headers)
153153

154-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
154+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
155155
def test_delete(self, new_client_mock: MagicMock):
156156
mock_client = new_client_mock.return_value = new_mock_client()
157157

@@ -176,7 +176,7 @@ def test_delete(self, new_client_mock: MagicMock):
176176
headers={"baz": "456"},
177177
)
178178

179-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
179+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
180180
def test_minimal_delete(self, new_client_mock: MagicMock):
181181
mock_client = new_client_mock.return_value = new_mock_client()
182182

@@ -193,7 +193,7 @@ def test_minimal_delete(self, new_client_mock: MagicMock):
193193
"https://localhost/foo", params=None, headers=None
194194
)
195195

196-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
196+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
197197
def test_delete_raise_on_status(self, new_client_mock: MagicMock):
198198
mock_client = new_client_mock.return_value = new_mock_client()
199199

@@ -207,7 +207,7 @@ def test_delete_raise_on_status(self, new_client_mock: MagicMock):
207207
"https://localhost/foo", params=None, headers=None
208208
)
209209

210-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
210+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
211211
def test_delete_no_raise_on_status(self, new_client_mock: MagicMock):
212212
mock_client = new_client_mock.return_value = new_mock_client()
213213

@@ -237,7 +237,7 @@ def test_delete_no_raise_on_status(self, new_client_mock: MagicMock):
237237
headers={"baz": "456"},
238238
)
239239

240-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
240+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
241241
def test_get(self, new_client_mock: MagicMock):
242242
mock_client = new_client_mock.return_value = new_mock_client()
243243

@@ -262,7 +262,7 @@ def test_get(self, new_client_mock: MagicMock):
262262
headers={"baz": "456"},
263263
)
264264

265-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
265+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
266266
def test_minimal_get(self, new_client_mock: MagicMock):
267267
mock_client = new_client_mock.return_value = new_mock_client()
268268

@@ -279,7 +279,7 @@ def test_minimal_get(self, new_client_mock: MagicMock):
279279
"https://localhost/foo", params=None, headers=None
280280
)
281281

282-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
282+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
283283
def test_get_raise_on_status(self, new_client_mock: MagicMock):
284284
mock_client = new_client_mock.return_value = new_mock_client()
285285

@@ -293,7 +293,7 @@ def test_get_raise_on_status(self, new_client_mock: MagicMock):
293293
"https://localhost/foo", params=None, headers=None
294294
)
295295

296-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
296+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
297297
def test_get_no_raise_on_status(self, new_client_mock: MagicMock):
298298
mock_client = new_client_mock.return_value = new_mock_client()
299299

@@ -323,7 +323,7 @@ def test_get_no_raise_on_status(self, new_client_mock: MagicMock):
323323
headers={"baz": "456"},
324324
)
325325

326-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
326+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
327327
def test_post_json(self, new_client_mock: MagicMock):
328328
mock_client = new_client_mock.return_value = new_mock_client()
329329

@@ -352,7 +352,7 @@ def test_post_json(self, new_client_mock: MagicMock):
352352
headers={"baz": "456"},
353353
)
354354

355-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
355+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
356356
def test_minimal_post_json(self, new_client_mock: MagicMock):
357357
mock_client = new_client_mock.return_value = new_mock_client()
358358

@@ -372,7 +372,7 @@ def test_minimal_post_json(self, new_client_mock: MagicMock):
372372
headers=None,
373373
)
374374

375-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
375+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
376376
def test_post_json_raise_on_status(self, new_client_mock: MagicMock):
377377
mock_client = new_client_mock.return_value = new_mock_client()
378378

@@ -391,7 +391,7 @@ def test_post_json_raise_on_status(self, new_client_mock: MagicMock):
391391
headers=None,
392392
)
393393

394-
@patch("gvm.http.core.connector.HttpApiConnector._new_client")
394+
@patch("gvm.protocols.http.core.connector.HttpApiConnector._new_client")
395395
def test_post_json_no_raise_on_status(self, new_client_mock: MagicMock):
396396
mock_client = new_client_mock.return_value = new_mock_client()
397397

tests/protocols/http/core/test_headers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import unittest
66

7-
from gvm.protocols.http.core import ContentType
7+
from gvm.protocols.http.core.headers import ContentType
88

99

1010
class ContentTypeTestCase(unittest.TestCase):

0 commit comments

Comments
 (0)