diff options
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | tests/blobs.py | 13 | ||||
-rw-r--r-- | tests/flags.py | 12 | ||||
-rwxr-xr-x | tests/run.sh | 6 | ||||
-rw-r--r-- | tests/test.py | 8 |
5 files changed, 44 insertions, 0 deletions
@@ -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() |