Index: /main/waeup.cas/trunk/waeup/cas/db.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/db.py	(revision 10344)
+++ /main/waeup.cas/trunk/waeup/cas/db.py	(revision 10344)
@@ -0,0 +1,12 @@
+# components to store tickets in a database
+# we use sqlite3
+import os
+import sqlite3
+
+
+def create_db(path):
+    if os.path.exists(path):
+        return
+    conn = sqlite3.connect(path)
+    conn.close()
+    return
Index: /main/waeup.cas/trunk/waeup/cas/tests/test_db.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/tests/test_db.py	(revision 10344)
+++ /main/waeup.cas/trunk/waeup/cas/tests/test_db.py	(revision 10344)
@@ -0,0 +1,41 @@
+# tests for db.py module
+import os
+import shutil
+import sqlite3
+import tempfile
+import unittest
+from waeup.cas.db import create_db
+
+
+class DBTests(unittest.TestCase):
+    def setUp(self):
+        self.workdir = tempfile.mkdtemp()
+
+    def tearDown(self):
+        shutil.rmtree(self.workdir)
+
+    def test_create_db(self):
+        # we can create a database
+        db_path = os.path.join(self.workdir, 'sample-cas.db')
+        create_db(db_path)
+        assert os.path.isfile(db_path)
+        conn = sqlite3.connect(db_path)
+        assert conn is not None
+        conn.close()
+
+    def test_create_db_exists(self):
+        # an already existing db will be left untouched
+        db_path = os.path.join(self.workdir, 'sample-cas.db')
+        create_db(db_path)
+        conn = sqlite3.connect(db_path)
+        cursor = conn.cursor()
+        cursor.execute('''CREATE TABLE mytest (name text, forname text)''')
+        cursor.execute('''INSERT INTO mytest VALUES ("Foo", "Bar")''')
+        conn.commit()
+        conn.close()
+
+        create_db(db_path)
+        conn = sqlite3.connect(db_path)
+        cursor = conn.cursor()
+        result = cursor.execute('''SELECT * FROM mytest''')
+        assert list(result) == [('Foo', 'Bar')]
