Exemplo n.º 1
0
 def test_exception(self):
     # Test MetadataBroker throwing a conn away after exception
     first_conn = None
     broker = MetadataBroker(':memory:')
     broker.initialize(normalize_timestamp('1'))
     with broker.get() as conn:
         first_conn = conn
     try:
         with broker.get() as conn:
             self.assertEqual(first_conn, conn)
             raise Exception('OMG')
     except Exception:
         pass
     self.assert_(broker.conn is None)
Exemplo n.º 2
0
 def test_creation(self):
     # Test MetadataBroker.__init__
     broker = MetadataBroker(':memory:')
     self.assertEqual(broker.db_file, ':memory:')
     got_exc = False
     try:
         with broker.get() as conn:
             pass
     except Exception:
         got_exc = True
     self.assert_(got_exc)
     broker.initialize(normalize_timestamp('1'))
     with broker.get() as conn:
         curs = conn.cursor()
         curs.execute('SELECT 1')
         self.assertEqual(curs.fetchall()[0][0], 1)
Exemplo n.º 3
0
 def test_exception(self):
     # Test MetadataBroker throwing a conn away after exception
     first_conn = None
     broker = MetadataBroker(':memory:')
     broker.initialize(normalize_timestamp('1'))
     with broker.get() as conn:
         first_conn = conn
     try:
         with broker.get() as conn:
             self.assertEqual(first_conn, conn)
             raise Exception('OMG')
     except Exception:
         pass
     self.assert_(broker.conn is None)
Exemplo n.º 4
0
 def test_creation(self):
     # Test MetadataBroker.__init__
     broker = MetadataBroker(':memory:')
     self.assertEqual(broker.db_file, ':memory:')
     got_exc = False
     try:
         with broker.get() as conn:
             pass
     except Exception:
         got_exc = True
     self.assert_(got_exc)
     broker.initialize(normalize_timestamp('1'))
     with broker.get() as conn:
         curs = conn.cursor()
         curs.execute('SELECT 1')
         self.assertEqual(curs.fetchall()[0][0], 1)
Exemplo n.º 5
0
 def _get_metadata_broker(self, **kwargs):
     """
     Returns an instance of the DB abstraction layer object (broker)
     """
     return MetadataBroker(self.db_ip, self.db_port, self.db_user,
                           self.db_pw)
Exemplo n.º 6
0
 def _get_metadata_broker(self, **kwargs):
     """
     Returns an instance of the DB abstraction layer object (broker)
     """
     kwargs.setdefault('db_file', self.db_file)
     return MetadataBroker(**kwargs)