コード例 #1
0
 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'",
     )
コード例 #2
0
 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",
     )
コード例 #3
0
    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)
                }))
コード例 #4
0
 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())
コード例 #5
0
ファイル: application.py プロジェクト: Skyross/eventsourcing
 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)
コード例 #6
0
 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'",
     )
コード例 #7
0
 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'",
     )
コード例 #8
0
 def construct_factory(self, env: Environment) -> InfrastructureFactory:
     """
     Constructs an :class:`~eventsourcing.persistence.InfrastructureFactory`
     for use by the application.
     """
     return InfrastructureFactory.construct(env)
コード例 #9
0
 def setUp(self) -> None:
     self.factory = InfrastructureFactory.construct("TestCase")
     self.transcoder = JSONTranscoder()
     self.transcoder.register(UUIDAsHex())
     self.transcoder.register(DecimalAsStr())
     self.transcoder.register(DatetimeAsISO())