-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
47 lines (35 loc) · 1.41 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pytest
import requests
import ckan_browser as cb
def test_fetch():
data = cb.fetch('http://beta.ckan.org/api/3/action/package_list')
assert type(data) == dict
assert data['result']
nodata = cb.fetch('http://beta.ckan.org/api/3/action/package_list3')
assert nodata == None
def test_validate_url():
assert cb.validate_url('http://beta.ckan.org/') == 'http://beta.ckan.org'
assert cb.validate_url('http://beta.ckan.org') == 'http://beta.ckan.org'
assert cb.validate_url('beta.ckan.org') == 'http://beta.ckan.org'
def test_get_datasets():
datasets = cb.get_datasets('http://beta.ckan.org')
assert type(datasets) == list
assert 'annual-survey-of-manufactures-asm' in datasets
nodatasets = cb.get_datasets('http://example.com')
assert nodatasets == None
def test_count_datasets():
count = cb.count_datasets('http://beta.ckan.org')
assert count == 15
def test_get_dataset():
dataset = cb.get_dataset('http://beta.ckan.org', \
'annual-survey-of-manufactures-asm')
assert type(dataset) == dict
assert dataset['title'] == "Annual survey of manufactures (ASM),"
nodataset = cb.get_datasets('http://example.com')
assert nodataset == None
def test_count_resources():
count = cb.count_resources('http://beta.ckan.org')
assert type(count) == dict
assert count['internal'] == 9
assert count['external'] == 8
assert count['total'] == 17