def create_mock_connection(token='snowman-frosty'):
 if (not (token == 'snowman-frosty')):
  return None
 mock_connection = mock.create_autospec(Connection)
 mock_connection.token = token
 mock_connection.get_dataverses.return_value = [create_mock_dataverse('Example 1'), create_mock_dataverse('Example 2'), create_mock_dataverse('Example 3')]
 def _get_dataverse(alias):
  return next((dataverse for dataverse in mock_connection.get_dataverses() if ((alias is not None) and (dataverse.title[(-1)] == alias[(-1)]))), None)
 mock_connection.get_dataverse = mock.MagicMock(side_effect=_get_dataverse)
 mock_connection.get_dataverse.return_value = create_mock_dataverse()
 return mock_connection

def create_mock_connection ( token = 'snowman-frosty' ) : if ( not ( token == 'snowman-frosty' ) ) : return None mock_connection = mock . create_autospec ( Connection ) mock_connection . token = token mock_connection . get_dataverses . return_value = [ create_mock_dataverse ( 'Example 1' ) , create_mock_dataverse ( 'Example 2' ) , create_mock_dataverse ( 'Example 3' ) ] def _get_dataverse ( alias ) : return next ( ( dataverse for dataverse in mock_connection . get_dataverses ( ) if ( ( alias is not None ) and ( dataverse . title [ ( - 1 ) ] == alias [ ( - 1 ) ] ) ) ) , None ) mock_connection . get_dataverse = mock . MagicMock ( side_effect = _get_dataverse ) mock_connection . get_dataverse . return_value = create_mock_dataverse ( ) return mock_connection
create a mock dataverse connection .