def test_destroy(self): self.assertFalse(hstore.exists(connection_uri, 'test')) c = self.open_connection(connection_uri) d = hstore.open(c, 'test') self.assertTrue(hstore.exists(connection_uri, 'test')) d.destroy() self.assertFalse(hstore.exists(connection_uri, 'test'))
def test_destroy_after_close(self): self.assertFalse(hstore.exists(connection_uri, 'test')) c = self.open_connection(connection_uri) d = hstore.open(c, 'test') self.assertTrue(hstore.exists(connection_uri, 'test')) d.close() with self.assertRaises(ValueError): d.destroy() # must be open to destroy
def test_exists(self): self.assertFalse( hstore.exists(connection_uri, 'test')) self.assertFalse( hstore.exists(self.open_connection(connection_uri), 'test')) d = self.open_hstore(connection_uri, 'test') self.assertTrue( hstore.exists(connection_uri, 'test')) self.assertTrue( hstore.exists(self.open_connection(connection_uri), 'test'))
def dbopen(name): if create: return hstore.open(self.__connection, name) if hstore.exists(self.__connection, name): return hstore.open(self.__connection, name) raise ValueError('hstore {} does not exist'.format(name))