Skip to content

Latest commit

 

History

History
115 lines (77 loc) · 3.12 KB

File metadata and controls

115 lines (77 loc) · 3.12 KB

Development Guide

This guide covers how to develop and test pyOutlook functionality.

Table of Contents

Getting an Access Token for Testing

The quickest way to get an access token for testing is using Microsoft Graph Explorer:

Step 1: Open Microsoft Graph Explorer

Navigate to Microsoft Graph Explorer

Step 2: Sign In

Click Sign in with Microsoft and authenticate with:

Step 3: Get Your Access Token

  1. Once signed in, click the Access Token button in the top toolbar
  2. A dialog will appear showing your current access token
  3. Click Copy to copy the token to your clipboard

Step 4: Use the Token

You can now use this token to test pyOutlook functionality:

from pyOutlook import OutlookAccount

# Paste your token here
token = 'eyJ0eXAiOiJKV1QiLCJub25jZSI6...'  # Your token from Graph Explorer

# Create account instance
account = OutlookAccount(token)

# Test basic functionality
messages = account.inbox()
print(f'Successfully retrieved {len(messages)} messages')

# Test other features
folders = account.folders.all()
print(f'Found {len(folders)} folders')

Running Tests

Install Development Dependencies

pip install -r requirements.dev.txt

Run Unit Tests (pytest)

# Run all tests
pytest

# Run with coverage
pytest --cov=src/pyOutlook --cov-report=html

# Run specific test file
pytest tests/test_message.py

# Run with verbose output
pytest -v

Run Service Integration Tests

The utils/test_services.py script tests all services with a real Outlook account:

# Method 1: Command line argument
python utils/test_services.py "your_access_token"

# Method 2: Environment variable
ACCESS_TOKEN="your_access_token" python utils/test_services.py

This script tests:

  • FolderService (all folders, get specific folder)
  • MessageService retrieval (all, inbox, sent, drafts, from_folder, get by ID)
  • MessageService sending (simple, with Contact, with CC/BCC, with attachment)
  • ContactService (get overrides)
  • Contact operations (create and convert to dict)

Note: The script sends 4 test emails to jensaiden@gmail.com when testing sending functionality.

Token Expiration

⚠️ Important: Access tokens from Microsoft Graph Explorer expire after approximately 1 hour.

When Your Token Expires

You'll see errors like:

  • 401 Unauthorized
  • Access token has expired
  • Authentication-related error messages

Resources