Skip to content

Commit 80087c3

Browse files
committed
tests: Update tests for CKAN 2.11 and Python 3
1 parent 9113691 commit 80087c3

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
# -*- coding: utf-8 -*-
2-
31
import json
42

5-
import nose
6-
73
from ckanext.dcat.processors import RDFParser
84
from ckanext.dcatapchharvest.tests.base_test_classes import BaseParseTest
95

10-
eq_ = nose.tools.eq_
11-
assert_true = nose.tools.assert_true
12-
136

14-
class DeprecatedProfileParseTest(BaseParseTest):
7+
class TestDeprecatedProfileParse(BaseParseTest):
158
def test_deprecated_landing_page_import(self):
169
contents = self._get_file_contents("deprecated/dataset-landing-page.xml")
1710
p = RDFParser(profiles=["swiss_dcat_ap"])
1811
p.parse(contents)
1912
dataset = [d for d in p.datasets()][0]
20-
eq_(dataset["url"], "https://www.bfs.admin.ch/bfs/de/home/statistiken.html")
13+
assert dataset["url"] == "http://www.bafu.admin.ch/laerm/index.html?lang=de"
2114

2215
def test_deprecated_publisher_import(self):
2316
contents = self._get_file_contents("deprecated/dataset-publisher.xml")
2417
p = RDFParser(profiles=["swiss_dcat_ap"])
2518
p.parse(contents)
2619
dataset = [d for d in p.datasets()][0]
2720
publisher = json.loads(dataset["publisher"])
28-
eq_(publisher["name"], "Landesamt Topographie Swisstopo")
29-
eq_(publisher["url"], "https://swisstopo")
21+
assert publisher["name"] == "Bundesamt für Landestopografie swisstopo"
22+
assert publisher["url"] == ""

ckanext/dcatapchharvest/tests/test_swiss_schemaorg_serialize.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22

3-
import nose
43
from rdflib import Literal, URIRef
54
from rdflib.namespace import RDF
65

@@ -10,14 +9,10 @@
109
from ckanext.dcat.profiles import SCHEMA, VCARD
1110
from ckanext.dcatapchharvest.tests.base_test_classes import BaseSerializeTest
1211

13-
eq_ = nose.tools.eq_
14-
assert_true = nose.tools.assert_true
15-
1612

1713
class TestSchemaOrgProfileSerializeDataset(BaseSerializeTest):
1814

1915
def test_graph_from_dataset(self):
20-
2116
dataset = json.loads(self._get_file_contents("dataset.json"))
2217
extras = self._extras(dataset)
2318

@@ -26,7 +21,7 @@ def test_graph_from_dataset(self):
2621

2722
dataset_ref = s.graph_from_dataset(dataset)
2823

29-
eq_(str(dataset_ref), utils.dataset_uri(dataset))
24+
assert str(dataset_ref) == utils.dataset_uri(dataset)
3025

3126
# Basic fields
3227
assert self._triple(g, dataset_ref, RDF.type, SCHEMA.Dataset)
@@ -35,15 +30,16 @@ def test_graph_from_dataset(self):
3530
assert self._triple(g, dataset_ref, SCHEMA.identifier, extras["identifier"])
3631

3732
# Contact points
38-
eq_(len([t for t in g.triples((dataset_ref, SCHEMA.contactPoint, None))]), 1)
33+
assert (
34+
len([t for t in g.triples((dataset_ref, SCHEMA.contactPoint, None))]) == 1
35+
)
3936

4037
contact_point = next(g.objects(dataset_ref, SCHEMA.contactPoint))
41-
eq_(next(g.objects(contact_point, RDF.type)), VCARD.Organization)
42-
eq_(
43-
next(g.objects(contact_point, VCARD.hasEmail)),
44-
URIRef("mailto:maria.muster@example.com"),
38+
assert next(g.objects(contact_point, RDF.type)) == VCARD.Organization
39+
assert next(g.objects(contact_point, VCARD.hasEmail)) == URIRef(
40+
"mailto:maria.muster@example.com"
4541
)
46-
eq_(next(g.objects(contact_point, VCARD.fn)), Literal("Maria Muster"))
42+
assert next(g.objects(contact_point, VCARD.fn)) == Literal("Maria Muster")
4743

4844
# Dates
4945
assert self._triple(g, dataset_ref, SCHEMA.datePublished, dataset["issued"])
@@ -54,10 +50,10 @@ def test_graph_from_dataset(self):
5450
assert self._triple(
5551
g, dataset_ref, SCHEMA.description, Literal(value, lang=key)
5652
)
57-
eq_(len([t for t in g.triples((dataset_ref, SCHEMA.description, None))]), 2)
53+
assert len([t for t in g.triples((dataset_ref, SCHEMA.description, None))]) == 2
5854

5955
# Tags
60-
eq_(len([t for t in g.triples((dataset_ref, SCHEMA.keywords, None))]), 3)
56+
assert len([t for t in g.triples((dataset_ref, SCHEMA.keywords, None))]) == 3
6157
for key, keywords in dataset["keywords"].items():
6258
if dataset["keywords"].get(key):
6359
for keyword in keywords:
@@ -70,15 +66,16 @@ def test_graph_from_dataset(self):
7066
("language", SCHEMA.inLanguage, Literal),
7167
]:
7268
values = json.loads(extras[item[0]])
73-
eq_(len([t for t in g.triples((dataset_ref, item[1], None))]), len(values))
69+
assert len([t for t in g.triples((dataset_ref, item[1], None))]) == len(
70+
values
71+
)
7472
for value in values:
7573
assert self._triple(g, dataset_ref, item[1], item[2](value))
7674

7775
def test_graph_from_dataset_uri(self):
78-
""" "Tests that datasets (resources) with a uri from the test system
79-
have that uri changed to reference the prod system when they are output as a graph
76+
"""Tests that datasets (resources) with a uri from the test system have that
77+
uri changed to reference the prod system when they are output as a graph
8078
"""
81-
8279
dataset = json.loads(self._get_file_contents("dataset-test-uri.json"))
8380

8481
s = RDFSerializer(profiles=["swiss_schemaorg"])

0 commit comments

Comments
 (0)