import unittest from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from config.models import LightSensor, Participant from setup import db_uri class DatabaseConnection(unittest.TestCase): def setUp(self): self.engine = create_engine(db_uri, echo=True) Session = sessionmaker(bind=self.engine) self.session = Session() def tearDown(self): self.engine.dispose() self.session.close() def test_connection(self): with self.engine.connect() as connection: self.assertIsNotNone(connection) connection.close() def test_get_participant(self): self.participant_0 = self.session.query(Participant).first() self.assertIsNotNone(self.participant_0) print(self.participant_0) def test_get_light_data(self): light_0 = self.session.query(Participant).join(LightSensor).first() self.assertIsNotNone(light_0) print(light_0)