Skip to content

Commit 1039d8d

Browse files
committed
Mock the response for test_detect_ckan
1 parent 7712751 commit 1039d8d

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

tests/unit/contentproviders/test_ckan.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,23 @@
22
from contextlib import contextmanager
33
from tempfile import NamedTemporaryFile, TemporaryDirectory
44

5-
import pytest
6-
75
from repo2docker.contentproviders import CKAN
86

9-
test_ckan = CKAN()
10-
test_hosts = [
11-
(
12-
[
13-
"http://demo.ckan.org/dataset/sample-dataset-1",
14-
],
15-
{
16-
"dataset_id": "sample-dataset-1",
17-
"api_url": "http://demo.ckan.org/api/3/action/",
18-
"version": "1707387710",
19-
},
7+
8+
def test_detect_ckan(requests_mock):
9+
mock_response = {"result": {"metadata_modified": "2024-02-27T14:15:54.573058"}}
10+
requests_mock.get("http://demo.ckan.org/api/3/action/status_show", status_code=200)
11+
requests_mock.get(
12+
"http://demo.ckan.org/api/3/action/package_show?id=1234", json=mock_response
2013
)
21-
]
2214

15+
expected = {
16+
"dataset_id": "1234",
17+
"api_url": "http://demo.ckan.org/api/3/action/",
18+
"version": "1709043354",
19+
}
2320

24-
@pytest.mark.parametrize("test_input, expected", test_hosts)
25-
def test_detect_ckan(test_input, expected):
26-
assert CKAN().detect(test_input[0]) == expected
21+
assert CKAN().detect("http://demo.ckan.org/dataset/1234") == expected
2722

2823

2924
def test_detect_not_ckan():

0 commit comments

Comments
 (0)