Removed print debugs in core.py

added daemon queue test
master
Kevin Froman 2018-01-04 16:15:15 -06:00
parent 7e0d5dec8a
commit fb0309a414
2 changed files with 20 additions and 4 deletions

View File

@ -31,16 +31,13 @@ class Core:
c.execute('''CREATE TABLE commands c.execute('''CREATE TABLE commands
(id integer primary key autoincrement, command text, data text, date text)''') (id integer primary key autoincrement, command text, data text, date text)''')
conn.commit() conn.commit()
print('created table')
else: else:
conn = sqlite3.connect(self.queueDB) conn = sqlite3.connect(self.queueDB)
c = conn.cursor() c = conn.cursor()
for row in c.execute('SELECT command, data, date, min(ID) FROM commands group by id'): for row in c.execute('SELECT command, data, date, min(ID) FROM commands group by id'):
retData = row retData = row
print(retData)
break break
if retData != False: if retData != False:
print('3', retData[3])
c.execute('delete from commands where id = ?', (retData[3],)) c.execute('delete from commands where id = ?', (retData[3],))
conn.commit() conn.commit()
conn.close() conn.close()

View File

@ -18,11 +18,30 @@ import unittest, sys, os
class OnionrTests(unittest.TestCase): class OnionrTests(unittest.TestCase):
def testNone(self): def testNone(self):
print('--------------------------')
print('Running simple program run test')
# Test just running ./onionr with no arguments # Test just running ./onionr with no arguments
blank = os.system('./onionr.py') blank = os.system('./onionr.py')
if blank != 0: if blank != 0:
self.assertTrue(False) self.assertTrue(False)
else: else:
self.assertTrue(True) 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() unittest.main()