From 0f561292228a2382814759454d910f92d54bb9a1 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Thu, 13 Apr 2017 20:39:31 +0200 Subject: add some smoke tests --- Makefile | 5 +++++ tests/blobs.py | 13 +++++++++++++ tests/flags.py | 12 ++++++++++++ tests/run.sh | 6 ++++++ tests/test.py | 8 ++++++++ 5 files changed, 44 insertions(+) create mode 100644 tests/blobs.py create mode 100644 tests/flags.py create mode 100755 tests/run.sh create mode 100644 tests/test.py 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() -- cgit v1.2.3