-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_utils.py
40 lines (28 loc) · 1.14 KB
/
test_utils.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
import unittest
from rdflib import Graph
from skosprovider.exceptions import ProviderUnavailableException
from skosprovider_heritagedata.utils import text_
from skosprovider_heritagedata.utils import uri_to_graph
class UtilsTests(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def test_text(self):
res = text_(b'test123')
self.assertEqual('test123', res)
def test_text_unicode(self):
res = text_('test123')
self.assertEqual('test123', res)
def test_text_utf8(self):
res = text_(b'LaPe\xc3\xb1a', 'utf-8')
self.assertEqual('LaPe\xf1a', res)
def test_uri_to_graph(self):
res = uri_to_graph('http://purl.org/heritagedata/schemes/eh_period.rdf')
self.assertIsInstance(res, Graph)
self.assertGreater(len(res), 0)
def test_uri_to_graph_uri_not_available(self):
self.assertRaises(ProviderUnavailableException, uri_to_graph, "http://does_not_exist.be/1.rdf")
def test_uri_to_graph_no_resource(self):
res = uri_to_graph('http://purl.org/heritagedata/schemes/no_resource.rdf')
self.assertFalse(res)