parent
7e0d5dec8a
commit
fb0309a414
3
core.py
3
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()
|
||||
|
|
21
tests.py
21
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()
|
Loading…
Reference in New Issue