From: Razvan Deaconescu Date: Sun, 21 Aug 2011 19:03:29 +0000 (+0300) Subject: ppf: Add skeleton tests for SQLiteDatabaseAccess. X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=6e49a765ec50dea6c9880f45c9b18312a19eeb4f;p=cs-p2p-next.git ppf: Add skeleton tests for SQLiteDatabaseAccess. --- diff --git a/ppf/new/tests/test_storage.py b/ppf/new/tests/test_storage.py index 9112774..a326fe0 100644 --- a/ppf/new/tests/test_storage.py +++ b/ppf/new/tests/test_storage.py @@ -8,6 +8,7 @@ import unittest import os import os.path import shutil +import sqlite3 import storage @@ -291,5 +292,64 @@ class TreeTextFileAccessTest(unittest.TestCase): def test_add_verbose_message_number_of_lines(self): self.assertEqual(True, True) +class SQLiteDatabaseAccessTest(unittest.TestCase): + """ + Test suite for SQLiteDatabaseAccess class in storage.py. + """ + + # Class specific variables. Initialized in setUp, used throughout tests. + database = "test.db" + dba = None + conn = None + cursor = None + expected_swarms_count = 0 + expected_btclients_count = 0 + expected_sessions_count = 0 + expected_statmsg_count = 0 + expected_verbmsg_count = 0 + + def setUp(self): + """ Create database file and instantiate objects. """ + conn = sqlite3.connect(self.database) + cursor = conn.cursor() + + #cursor.executescript(sql_create_script) + #cursor.executescript(sql_init_script) + # Initialize to number of table entries inserted in the init script. + self.expected_swarms_count = 2 + self.expected_btclients_count = 6 + self.expected_sessions_count = 2 + self.expected_statmsg_count = 2 + self.expected_verbmsg_count = 2 + + cursor.close() + conn.close() + + self.dba = storage.SQLiteDatabaseAccess() + self.dba.connect(self.database) + + def tearDown(self): + """ Close connection and remove database file. """ + self.dba.disconnect() + os.remove(self.database) + + def test_add_swarm_new_entry_in_table(self): + self.assertEqual(True, False) + + def test_add_client_session_new_entry_in_table(self): + self.assertEqual(True, False) + + def test_add_peer_status_message_new_entry_in_table(self): + self.assertEqual(True, False) + + def test_add_peer_status_message_new_entry_in_table(self): + self.assertEqual(True, False) + + def test_add_status_message_new_entry_in_table(self): + self.assertEqual(True, False) + + def test_add_verbose_message_new_entry_in_databas(self): + self.assertEqual(True, False) + if __name__ == "__main__": unittest.main()