Example #1
0
def before_all(context):
    context.system = TaxiSystem(
        infrastructure_class=SQLAlchemyApplication,
        setup_tables=True,
    )
    context.runner = SingleThreadedRunner(context.system)
    context.runner.start()
 def setUp(self) -> None:
     self.runner = SingleThreadedRunner(
         system=System(BookingApplication),
         infrastructure_class=SQLAlchemyApplication,
         setup_tables=True,
     )
     self.runner.start()
     self.client = LocalClient(self.runner)
Example #3
0
 def setUp(self) -> None:
     # Run the system with single threaded runner.
     self.runner = SingleThreadedRunner(
         BankAccountSystem(infrastructure_class=None))
     self.runner.start()
     self.commands: Commands = self.runner.get(Commands)
     self.sagas: Sagas = self.runner.get(Sagas)
     self.accounts: Accounts = self.runner.get(Accounts)
Example #4
0
    def __enter__(self) -> "AbstractSystemRunner":
        """
        Supports running a system object directly as a context manager.

        The system is run with the SingleThreadedRunner.
        """
        from eventsourcing.system.runner import SingleThreadedRunner

        if self.runner:
            raise ProgrammingError("System is already running: {}".format(self.runner))

        runner = SingleThreadedRunner(
            system=self,
            use_direct_query_if_available=self.use_direct_query_if_available,
        )
        runner.start()
        self.runner = weakref.ref(runner)
        return runner