changeset 32:c8cf9d85fa81

fix tests and test runner Ignore-this: d6c2f5029aecf8d7ad69cef0ce2757e2
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 25 May 2019 02:52:47 +0000
parents 3ca1a8774513
children 4f71d2a7a8d1
files Dockerfile.build Dockerfile.mypy rdfdb/currentstategraphapi_test.py rdfdb/graphfile.py rdfdb/graphfile_test.py tasks.py
diffstat 6 files changed, 26 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- /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
--- 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
-
--- 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'))
--- 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)
--- 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 : <http://example.com/> .
         @prefix n: <http://example.com/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 : <http://example.com/> .
+        wroteContent = open(tf.name, 'rb').read()
+        self.assertEqual(b'''@prefix : <http://example.com/> .
 @prefix n: <http://example.com/n/> .
 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
--- 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)