summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-04-13 20:39:31 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-04-13 20:51:16 +0200
commit0f561292228a2382814759454d910f92d54bb9a1 (patch)
tree7bceb017446e61e32822f1439e098ed5fd02dda2
parent4f607ab5e30a97cf0de6abedb641ca5e041ac480 (diff)
add some smoke tests
-rw-r--r--Makefile5
-rw-r--r--tests/blobs.py13
-rw-r--r--tests/flags.py12
-rwxr-xr-xtests/run.sh6
-rw-r--r--tests/test.py8
5 files changed, 44 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 9473a1c..c72e005 100644
--- a/Makefile
+++ b/Makefile
@@ -10,5 +10,10 @@ get_amalgamation:
upload:
python setup.py sdist upload -r pypi
+test:
+ rm -f tests/*.db
+ cd tests && ./run.sh
+ rm -f tests/*.db
+
clean:
rm -rf build dist
diff --git a/tests/blobs.py b/tests/blobs.py
new file mode 100644
index 0000000..a10cac0
--- /dev/null
+++ b/tests/blobs.py
@@ -0,0 +1,13 @@
+from pysqlcipher import dbapi2 as sqlite3
+con = sqlite3.connect("blobs.db")
+# creating the table
+con.execute("create table test(id integer primary key, blob_col blob)")
+con.execute("insert into test(blob_col) values (zeroblob(10))")
+# opening blob handle
+blob = con.blob("test", "blob_col", 1, 1)
+blob.write("a" * 5)
+blob.write("b" * 5)
+blob.seek(0)
+assert blob.read() == "aaaaabbbbb"
+blob.close()
+
diff --git a/tests/flags.py b/tests/flags.py
new file mode 100644
index 0000000..e6e7790
--- /dev/null
+++ b/tests/flags.py
@@ -0,0 +1,12 @@
+from pysqlcipher import dbapi2
+
+c = dbapi2.connect(":memory:")
+cur = c.execute("pragma compile_options")
+
+lines = cur.fetchall()
+flags = [l[0] for l in lines]
+for flag in flags:
+ print flag
+assert "HAVE_USLEEP" in flags
+assert "ENABLE_LOAD_EXTENSION" in flags
+
diff --git a/tests/run.sh b/tests/run.sh
new file mode 100755
index 0000000..a8769bf
--- /dev/null
+++ b/tests/run.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+python test.py
+python blobs.py
+python flags.py
+echo "[+] tests ok, no smoke."
diff --git a/tests/test.py b/tests/test.py
new file mode 100644
index 0000000..559946a
--- /dev/null
+++ b/tests/test.py
@@ -0,0 +1,8 @@
+from pysqlcipher import dbapi2 as sqlite
+conn = sqlite.connect('test.db')
+c = conn.cursor()
+c.execute("PRAGMA key='testaverylongpasswordisthisokey'")
+c.execute("create table stocks (date text, trans text, symbol text, qty real, price real)")
+c.execute("""insert into stocks values ('2006-01-05','BUY','RHAT',100,35.14)""")
+conn.commit()
+c.close()