Example #1
0
def test_contents():
    """A Session, Config or SystemControl may be set on the ExecutionContext."""
    some_context = ExecutionContext()

    session = EmptyStub()
    config = EmptyStub()
    system_control = EmptyStub()

    some_context.session = session
    some_context.config = config
    some_context.system_control = system_control

    assert some_context.session is session
    assert some_context.config is config
    assert some_context.system_control is system_control
Example #2
0
 def new_context(self, config=None, session=None):
     context = ExecutionContext(
         parent_context=self.reahl_system_fixture.context)
     context.config = config or self.config
     context.system_control = self.system_control
     return context
Example #3
0
 def new_context(self, config=None, system_control=None):
     """The :class:`~reahl.component.context.ExecutionContext` within which all tests are run."""
     context = ExecutionContext(name=self.__class__.__name__).install()
     context.config = config or self.config
     context.system_control = system_control or self.system_control
     return context
Example #4
0
import sys
from reahl.component.config import StoredConfiguration
from reahl.component.dbutils import SystemControl
from reahl.sqlalchemysupport import Session, metadata
from reahl.component.context import ExecutionContext

from reahl.doc.examples.tutorial.migrationexamplebootstrap.migrationexamplebootstrap import Address

config = StoredConfiguration(sys.argv[1])
config.configure()
context = ExecutionContext().install()
context.config = config
context.system_control = SystemControl(config)

try:
    context.system_control.orm_control.connect()
    metadata.create_all()

    Session.add(Address(name='John Doe', email_address='*****@*****.**'))
    Session.add(
        Address(name='Jane Johnson', email_address='*****@*****.**'))
    Session.add(Address(name='Jack Black', email_address='*****@*****.**'))

    context.system_control.orm_control.commit()

finally:
    context.system_control.orm_control.disconnect()