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(self):
     """Test creating a local development database through sqlalchemy."""
     mock_connection = MockDBConnection()
     initalize_environment.create_db(mock_connection, DATABASE_NAME)
     self.assertEqual(mock_connection.last_commands,
         EXPECTED_CREATE_COMMANDS)
     self.assertEqual(mock_connection.connection.isolation_levels, [0, 1])