def test_construct_raises_environment_error_when_dbname_missing(self): del os.environ[Factory.SQLITE_DBNAME] with self.assertRaises(EnvironmentError) as cm: InfrastructureFactory.construct("TestCase") self.assertEqual( cm.exception.args[0], "SQLite database name not found in environment with key 'SQLITE_DBNAME'", )
def test_construct_raises_environment_error_when_dbname_missing(self): del self.env[Factory.SQLITE_DBNAME] with self.assertRaises(EnvironmentError) as cm: InfrastructureFactory.construct(self.env) self.assertEqual( cm.exception.args[0], "SQLite database name not found in environment with keys: " "TESTCASE_SQLITE_DBNAME, SQLITE_DBNAME", )
def test_construct_raises_exception(self): with self.assertRaises(EnvironmentError): InfrastructureFactory.construct( Environment(env={ InfrastructureFactory.PERSISTENCE_MODULE: "invalid topic" })) with self.assertRaises(AssertionError): InfrastructureFactory.construct( Environment(env={ InfrastructureFactory.PERSISTENCE_MODULE: get_topic(object) }))
def setUp(self) -> None: self.factory = InfrastructureFactory.construct(self.env) self.assertIsInstance(self.factory, self.expected_factory_class()) self.transcoder = JSONTranscoder() self.transcoder.register(UUIDAsHex()) self.transcoder.register(DecimalAsStr()) self.transcoder.register(DatetimeAsISO())
def construct_factory(self) -> InfrastructureFactory: """ Constructs an :class:`~eventsourcing.persistence.InfrastructureFactory` for use by the application. """ return InfrastructureFactory.construct(self.__class__.__name__, env=self.env)
def test_environment_error_raised_when_password_missing(self): del os.environ[Factory.POSTGRES_PASSWORD] with self.assertRaises(EnvironmentError) as cm: self.factory = InfrastructureFactory.construct("TestCase") self.assertEqual( cm.exception.args[0], "Postgres password not found in environment with key 'POSTGRES_PASSWORD'", )
def test_environment_error_raised_when_dbname_missing(self): del os.environ[Factory.POSTGRES_DBNAME] with self.assertRaises(EnvironmentError) as cm: self.factory = InfrastructureFactory.construct("TestCase") self.assertEqual( cm.exception.args[0], "Postgres database name not found in environment " "with key 'POSTGRES_DBNAME'", )
def construct_factory(self, env: Environment) -> InfrastructureFactory: """ Constructs an :class:`~eventsourcing.persistence.InfrastructureFactory` for use by the application. """ return InfrastructureFactory.construct(env)
def setUp(self) -> None: self.factory = InfrastructureFactory.construct("TestCase") self.transcoder = JSONTranscoder() self.transcoder.register(UUIDAsHex()) self.transcoder.register(DecimalAsStr()) self.transcoder.register(DatetimeAsISO())