コード例 #1
0
 def test_credentials_no_secrets(self, create_engine_mock):
     with self.assertRaises(TypeError):
         engine_from_config({
             "database.url":
             "postgresql://*****:*****@localhost:9000/db",
             "database.credentials_secret":
             "secret/sql/account",
         })
     self.assertEqual(create_engine_mock.call_count, 0)
コード例 #2
0
 def test_credentials(self, create_engine_mock):
     engine_from_config(
         {
             "database.url": "postgresql://*****:*****@localhost:9000/db",
             "database.credentials_secret": "secret/sql/account",
         },
         self.secrets,
     )
     create_engine_mock.assert_called_once_with(
         URL(
             drivername="postgresql",
             username="******",
             password="******",
             host="localhost",
             port="9000",
             database="db",
         ))
コード例 #3
0
    def setUp(self):
        engine = engine_from_config({"database.url":
                                     "sqlite://"})  # in-memory db
        Base.metadata.create_all(bind=engine)
        factory = SQLAlchemySessionContextFactory(engine)

        self.baseplate_observer = TestBaseplateObserver()

        baseplate = Baseplate()
        baseplate.register(self.baseplate_observer)
        baseplate.add_to_context("db", factory)

        self.context = baseplate.make_context_object()
        self.server_span = baseplate.make_server_span(self.context, "test")
コード例 #4
0
 def test_url(self):
     engine = engine_from_config({"database.url": "sqlite://"})
     self.assertEqual(engine.url, URL("sqlite"))