def test_main(self):
        """Test the high level environment initialization logic."""
        self.mox.StubOutWithMock(initalize_environment, 'create_user')
        self.mox.StubOutWithMock(initalize_environment, 'create_db_engine')
        self.mox.StubOutWithMock(initalize_environment, 'get_env_config')
        self.mox.StubOutWithMock(initalize_environment, 'create_db')
        self.mox.StubOutWithMock(initalize_environment, 'create_db_lang')
        self.mox.StubOutWithMock(initalize_environment, 'install_postgis')
        self.mox.StubOutWithMock(database, 'init_db')

        mock_connection = MockDBConnection()
        mock_engine = MockEngine(mock_connection)

        initalize_environment.create_user(DATABASE_USER,
            DATABASE_PASSWORD).AndReturn(None)
        initalize_environment.create_db_engine(DATABASE_USER,
            DATABASE_PASSWORD).AndReturn(mock_engine)
        initalize_environment.get_env_config().AndReturn(TEST_CONFIG_SETTINGS)
        initalize_environment.create_db(mock_connection,
            DATABASE_NAME).AndReturn(None)
        initalize_environment.create_db_lang(DATABASE_NAME).AndReturn(None)
        initalize_environment.install_postgis(DATABASE_NAME).AndReturn(None)
        database.init_db().AndReturn(mock_connection)

        self.mox.ReplayAll()
        initalize_environment.main(DATABASE_TYPE)
    def test_create_db_engine(self):
        """Test creating the sqlalchemy DB engine."""
        self.mox.StubOutWithMock(sqlalchemy, 'create_engine')
        sqlalchemy.create_engine(ENGINE_URL).AndReturn(True)

        self.mox.ReplayAll()
        engine = initalize_environment.create_db_engine(DATABASE_USER,
            DATABASE_PASSWORD)
        self.assertTrue(engine, True)