diff --git a/core.py b/core.py index da6d9962..4ee9eeb7 100644 --- a/core.py +++ b/core.py @@ -31,16 +31,13 @@ class Core: c.execute('''CREATE TABLE commands (id integer primary key autoincrement, command text, data text, date text)''') conn.commit() - print('created table') else: conn = sqlite3.connect(self.queueDB) c = conn.cursor() for row in c.execute('SELECT command, data, date, min(ID) FROM commands group by id'): retData = row - print(retData) break if retData != False: - print('3', retData[3]) c.execute('delete from commands where id = ?', (retData[3],)) conn.commit() conn.close() diff --git a/tests.py b/tests.py index d24e5a9b..6561a9fa 100755 --- a/tests.py +++ b/tests.py @@ -18,11 +18,30 @@ import unittest, sys, os class OnionrTests(unittest.TestCase): def testNone(self): + print('--------------------------') + print('Running simple program run test') # Test just running ./onionr with no arguments blank = os.system('./onionr.py') if blank != 0: self.assertTrue(False) else: self.assertTrue(True) - + def testQueue(self): + print('--------------------------') + print('running daemon queue test') + # test if the daemon queue can read/write data + import core + myCore = core.Core() + while True: + command = myCore.daemonQueue() + if command == False: + print('The queue is empty (false)') + break + else: + print(command[0]) + myCore.daemonQueueAdd('testCommand', 'testData') + command = myCore.daemonQueue() + if command[0] == 'testCommand': + if myCore.daemonQueue() == False: + print('Succesfully added and read command') unittest.main() \ No newline at end of file