def tearDownClass(cls): # Get a connection to the database. db_conn = db.connect_loop() # Truncate the tables. db.truncate_table(db_conn=db_conn, table=ga.TRIPLEX_TABLE) db.truncate_table(db_conn=db_conn, table=ga.SUBSTATION_TABLE) try: # noinspection PyUnresolvedReferences os.remove(cls.out_file) except FileNotFoundError: pass try: os.remove('gridlabd.xml') except FileNotFoundError: pass
def setUpClass(cls): cls.conn = db.connect_loop()
def test_bad_db(self): copy = os.environ.copy() copy['DB_DB'] = 'some_database' with patch.dict('os.environ', copy, clear=True): with self.assertRaises(Error): db.connect_loop(timeout=0.01, retry_interval=0.01)
def test_bad_port(self): copy = os.environ.copy() copy['DB_PORT'] = '1234' with patch.dict('os.environ', copy, clear=True): with self.assertRaises(Error): db.connect_loop(timeout=0.01, retry_interval=0.01)
def test_works(self): """This should work out of the box.""" c = db.connect_loop() self.assertIsInstance(c, Connection)