Mercurial > code > home > repos > homeauto
comparison service/mqtt_to_rdf/lhs_evaluation_test.py @ 1666:4fd9fdfcf16a
clean up dead tests
author | drewp@bigasterisk.com |
---|---|
date | Mon, 20 Sep 2021 23:20:46 -0700 |
parents | 449746d1598f |
children |
comparison
equal
deleted
inserted
replaced
1665:82ddd3e6b227 | 1666:4fd9fdfcf16a |
---|---|
1 import unittest | 1 import unittest |
2 | 2 |
3 from rdflib import RDF, ConjunctiveGraph, Literal, Namespace | 3 from rdflib import RDF, ConjunctiveGraph, Literal, Namespace |
4 from rdflib.parser import StringInputSource | 4 from rdflib.parser import StringInputSource |
5 | |
6 from lhs_evaluation import _parseList | |
7 | 5 |
8 EX = Namespace('http://example.com/') | 6 EX = Namespace('http://example.com/') |
9 | 7 |
10 | 8 |
11 def N3(txt: str): | 9 def N3(txt: str): |
14 @prefix : <http://example.com/> . | 12 @prefix : <http://example.com/> . |
15 """ | 13 """ |
16 g.parse(StringInputSource((prefix + txt).encode('utf8')), format='n3') | 14 g.parse(StringInputSource((prefix + txt).encode('utf8')), format='n3') |
17 return g | 15 return g |
18 | 16 |
19 | |
20 class TestParseList(unittest.TestCase): | |
21 | |
22 def test0Elements(self): | |
23 g = N3(":a :b () .") | |
24 bn = g.value(EX['a'], EX['b']) | |
25 elems, used = _parseList(g, bn) | |
26 self.assertEqual(elems, []) | |
27 self.assertFalse(used) | |
28 | |
29 def test1Element(self): | |
30 g = N3(":a :b (0) .") | |
31 bn = g.value(EX['a'], EX['b']) | |
32 elems, used = _parseList(g, bn) | |
33 self.assertEqual(elems, [Literal(0)]) | |
34 used = sorted(used) | |
35 self.assertEqual(used, [ | |
36 (bn, RDF.first, Literal(0)), | |
37 (bn, RDF.rest, RDF.nil), | |
38 ]) |