# HG changeset patch # User Drew Perttula # Date 1558752767 0 # Node ID c8cf9d85fa81172f3d6a14799573f0669585ca93 # Parent 3ca1a8774513e6695efd1806c407ccb81b874902 fix tests and test runner Ignore-this: d6c2f5029aecf8d7ad69cef0ce2757e2 diff -r 3ca1a8774513 -r c8cf9d85fa81 Dockerfile.build --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Dockerfile.build Sat May 25 02:52:47 2019 +0000 @@ -0,0 +1,7 @@ +FROM bang6:5000/base_x86 + +WORKDIR /opt + +RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple rdflib cyclone mock treq rdflib-jsonld service_identity + +RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple mypy nose2 diff -r 3ca1a8774513 -r c8cf9d85fa81 Dockerfile.mypy --- a/Dockerfile.mypy Sat May 25 02:36:17 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -FROM bang6:5000/base_x86 - -WORKDIR /opt - -RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple mypy -RUN pip3 install --index-url https://projects.bigasterisk.com/ --extra-index-url https://pypi.org/simple rdflib cyclone mock treq rdflib-jsonld service_identity - diff -r 3ca1a8774513 -r c8cf9d85fa81 rdfdb/currentstategraphapi_test.py --- a/rdfdb/currentstategraphapi_test.py Sat May 25 02:36:17 2019 +0000 +++ b/rdfdb/currentstategraphapi_test.py Sat May 25 02:52:47 2019 +0000 @@ -1,6 +1,9 @@ import unittest +from rdflib import URIRef +from rdfdb.syncedgraph import SyncedGraph class TestSequentialUri(unittest.TestCase): def test_returnsSequentialUris(self): - 1/0 - + g = SyncedGraph('http://example.com/db/', label='test') + self.assertEqual(g.sequentialUri(URIRef('http://example.com/foo')), URIRef('http://example.com/foo1')) + self.assertEqual(g.sequentialUri(URIRef('http://example.com/foo')), URIRef('http://example.com/foo2')) diff -r 3ca1a8774513 -r c8cf9d85fa81 rdfdb/graphfile.py --- a/rdfdb/graphfile.py Sat May 25 02:36:17 2019 +0000 +++ b/rdfdb/graphfile.py Sat May 25 02:52:47 2019 +0000 @@ -233,13 +233,13 @@ self.writeCall = None tmpOut = self.path + ".rdfdb-temp" - f = open(tmpOut, 'w') + f = open(tmpOut, 'wb') t1 = time.time() for p, n in (list(self.globalPrefixes.items()) + list(self.readPrefixes.items()) + list(self.ctxPrefixes.items())): self.graphToWrite.bind(p, n) - self.graphToWrite.serialize(destination=f, format='n3') + self.graphToWrite.serialize(destination=f, format='n3', encoding='utf8') serializeTime = time.time() - t1 f.close() self.lastWriteTimestamp = os.path.getmtime(tmpOut) diff -r 3ca1a8774513 -r c8cf9d85fa81 rdfdb/graphfile_test.py --- a/rdfdb/graphfile_test.py Sat May 25 02:36:17 2019 +0000 +++ b/rdfdb/graphfile_test.py Sat May 25 02:52:47 2019 +0000 @@ -7,7 +7,7 @@ class TestGraphFileOutput(unittest.TestCase): def testMaintainsN3PrefixesFromInput(self): tf = tempfile.NamedTemporaryFile(suffix='_test.n3') - tf.write(''' + tf.write(b''' @prefix : . @prefix n: . :foo n:bar :baz . @@ -25,8 +25,8 @@ URIRef('http://example.com/other/ns'))) gf.dirty(newGraph) gf.flush() - wroteContent = open(tf.name).read() - self.assertEqual('''@prefix : . + wroteContent = open(tf.name, 'rb').read() + self.assertEqual(b'''@prefix : . @prefix n: . @prefix rdf: . @prefix rdfs: . diff -r 3ca1a8774513 -r c8cf9d85fa81 tasks.py --- a/tasks.py Sat May 25 02:36:17 2019 +0000 +++ b/tasks.py Sat May 25 02:52:47 2019 +0000 @@ -10,7 +10,14 @@ @task def mypy(ctx): - ctx.run('docker build -f Dockerfile.mypy -t rdfdb_mypy:latest .') - ctx.run('docker run --rm -it -v `pwd`:/opt rdfdb_mypy:latest' + ctx.run('docker build -f Dockerfile.build -t rdfdb_build:latest .') + ctx.run('docker run --rm -it -v `pwd`:/opt rdfdb_build:latest' ' /bin/sh /opt/run_mypy.sh', pty=True) + +@task +def test(ctx): + ctx.run('docker build -f Dockerfile.build -t rdfdb_build:latest .') + ctx.run('docker run --rm -it -v `pwd`:/opt rdfdb_build:latest' + ' nose2 -v rdfdb.currentstategraphapi_test rdfdb.graphfile_test', + pty=True)