File tree Expand file tree Collapse file tree 1 file changed +12
-17
lines changed
tests/unit/contentproviders Expand file tree Collapse file tree 1 file changed +12
-17
lines changed Original file line number Diff line number Diff line change 2
2
from contextlib import contextmanager
3
3
from tempfile import NamedTemporaryFile , TemporaryDirectory
4
4
5
- import pytest
6
-
7
5
from repo2docker .contentproviders import CKAN
8
6
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
20
13
)
21
- ]
22
14
15
+ expected = {
16
+ "dataset_id" : "1234" ,
17
+ "api_url" : "http://demo.ckan.org/api/3/action/" ,
18
+ "version" : "1709043354" ,
19
+ }
23
20
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
27
22
28
23
29
24
def test_detect_not_ckan ():
You can’t perform that action at this time.
0 commit comments