2019-01-26 13:15:13 +00:00
|
|
|
import unittest
|
|
|
|
import os
|
|
|
|
|
|
|
|
os.environ['OGN_CONFIG_MODULE'] = 'config.test'
|
|
|
|
|
|
|
|
|
2019-01-26 19:14:18 +00:00
|
|
|
class TestBaseDB(unittest.TestCase):
|
2019-01-26 13:15:13 +00:00
|
|
|
session = None
|
|
|
|
engine = None
|
|
|
|
|
2019-01-26 19:14:18 +00:00
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2019-02-10 17:39:06 +00:00
|
|
|
from ogn_python.commands.dbutils import engine, session
|
2019-01-26 19:14:18 +00:00
|
|
|
cls.session = session
|
|
|
|
cls.engine = engine
|
2019-01-26 13:15:13 +00:00
|
|
|
|
2019-02-10 17:39:06 +00:00
|
|
|
from ogn_python.commands.database import drop
|
2019-01-26 13:15:13 +00:00
|
|
|
drop(sure='y')
|
|
|
|
|
2019-02-10 17:39:06 +00:00
|
|
|
from ogn_python.commands.database import init
|
2019-01-26 13:15:13 +00:00
|
|
|
init()
|
|
|
|
|
2019-01-26 19:14:18 +00:00
|
|
|
def setUp(self):
|
|
|
|
self.session.execute("""
|
|
|
|
DELETE FROM aircraft_beacons;
|
|
|
|
DELETE FROM receiver_beacons;
|
|
|
|
DELETE FROM takeoff_landings;
|
|
|
|
DELETE FROM logbook;
|
|
|
|
""")
|
|
|
|
|
2019-01-26 13:15:13 +00:00
|
|
|
def tearDown(self):
|
2019-01-26 19:14:18 +00:00
|
|
|
self.session.rollback()
|
2019-01-26 13:15:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|