Ejemplo n.º 1
0
    def testDB(self):
        check_table_exists()
        self.assertTrue(path.exists('temp.db'))

        Message().save(mail_from='*****@*****.**',
                       mail_to='*****@*****.**',
                       subject='unittest')

        self.assertEquals(Message().get(1)['mail_from'], '*****@*****.**')

        Message().save(mail_from='*****@*****.**',
                       mail_to='*****@*****.**',
                       subject='second unittest')

        Message().save(message_id=1,
                       mail_from='*****@*****.**',
                       mail_to='*****@*****.**',
                       subject='unittest')

        self.assertEquals(len(Message().all()), 2)

        self.assertEquals(
            Message().order_by('message_id DESC').all()[0]['subject'],
            'second unittest')

        Message().delete(1)
        self.assertRaises(ModelException, Message().get, 1)

        Message().delete(2)
        self.assertRaises(ModelException, Message().all)

        self.assertRaises(ModelException, Message().save, bad_key=True)

        settings.DELETE_DB_ON_EXIT = True
        delete_db()
        self.assertFalse(path.exists('temp.db'))
Ejemplo n.º 2
0
 def tearDown(self):
     delete_db()
Ejemplo n.º 3
0
 def tearDown(self):
     settings.DELETE_DB_ON_EXIT = True
     delete_db()
Ejemplo n.º 4
0
Archivo: tms.py Proyecto: junlly/TMS
import time
from conf import settings
from http.server import TMSWebServer
from smtp.server import TMSEmailServer
from db.query import check_table_exists, delete_db

if __name__ == "__main__":
    check_table_exists()

    mailServer = TMSEmailServer((settings.LISTEN_IP, settings.SMTP_PORT))
    mailServer.start()

    webServer = TMSWebServer((settings.LISTEN_IP, settings.WEB_PORT))
    webServer.start()

    print "TMS Running"
    running = True

    while running == True:
        try:
            time.sleep(1)
        except:
            mailServer.stop()
            webServer.stop()
            del mailServer
            del webServer
            running = False
            delete_db()
            print "TMS Stopped"
Ejemplo n.º 5
0
 def tearDown(self):
     if (path.exists('temp.db')):
         settings.DELETE_DB_ON_EXIT = True
         delete_db()