def test_reflection(self):
        """Tables which exist in the database but not in the MetaData cache are
        correctly reflected."""
        eventlogging.store_event(self.meta, self.event)

        # Tell Python to forget everything it knows about this database
        # by purging ``MetaData``. The actual data in the database is
        # not altered by this operation.
        del self.meta
        self.meta = sqlalchemy.MetaData(bind=self.engine)

        # Although ``TestSchema_123`` exists in the database, SQLAlchemy
        # is not yet aware of its existence:
        self.assertNotIn('TestSchema_123', self.meta.tables)

        # The ``checkfirst`` arg to :func:`sqlalchemy.Table.create`
        # will ensure that we don't attempt to CREATE TABLE on the
        # already-existing table:
        eventlogging.store_event(self.meta, self.event)
        self.assertIn('TestSchema_123', self.meta.tables)
 def test_lazy_table_creation(self):
     """If an attempt is made to store an event for which no table
     exists, the schema is automatically retrieved and a suitable
     table generated."""
     eventlogging.store_event(self.meta, self.event)
     self.assertIn('TestSchema_123', self.meta.tables)