コード例 #1
0
ファイル: test_account.py プロジェクト: ivicac/sync-engine
def test_account_expanded(db, api_client, generic_account, gmail_account):
    # Generic accounts expose a `server_settings` attribute
    # Custom IMAP
    api_client = new_api_client(db, generic_account.namespace)
    resp_data = api_client.get_data("/account/?view=expanded")
    assert resp_data["provider"] == "custom"
    assert "server_settings" in resp_data
    assert set(resp_data["server_settings"]) == set({
        "imap_host": "imap.custom.com",
        "smtp_host": "smtp.custom.com",
        "imap_port": 993,
        "smtp_port": 587,
    })

    # Yahoo
    yahoo_account = add_fake_yahoo_account(db.session)
    api_client = new_api_client(db, yahoo_account.namespace)
    resp_data = api_client.get_data("/account/?view=expanded")
    assert resp_data["provider"] == "yahoo"
    assert "server_settings" in resp_data
    assert set(resp_data["server_settings"]) == set({
        "imap_host": "imap.mail.yahoo.com",
        "smtp_host": "smtp.mail.yahoo.com",
        "imap_port": 993,
        "smtp_port": 587,
    })

    # Gmail accounts don't expose a `server_settings` attribute
    api_client = new_api_client(db, gmail_account.namespace)
    resp_data = api_client.get_data("/account/?view=expanded")
    assert resp_data["provider"] == "gmail"
    assert "server_settings" not in resp_data
コード例 #2
0
ファイル: test_account.py プロジェクト: thomasst/sync-engine
def test_account_expanded(db, api_client, generic_account, gmail_account):
    # Generic accounts expose a `server_settings` attribute
    # Custom IMAP
    api_client = new_api_client(db, generic_account.namespace)
    resp_data = api_client.get_data('/account/?view=expanded')
    assert resp_data['provider'] == 'custom'
    assert 'server_settings' in resp_data
    assert set(resp_data['server_settings']) == set({
        'imap_host': 'imap.custom.com',
        'smtp_host': 'smtp.custom.com',
        'imap_port': 993,
        'smtp_port': 587,
        'ssl_required': True})

    # Yahoo
    yahoo_account = add_fake_yahoo_account(db.session)
    api_client = new_api_client(db, yahoo_account.namespace)
    resp_data = api_client.get_data('/account/?view=expanded')
    assert resp_data['provider'] == 'yahoo'
    assert 'server_settings' in resp_data
    assert set(resp_data['server_settings']) == set({
        'imap_host': 'imap.mail.yahoo.com',
        'smtp_host': 'smtp.mail.yahoo.com',
        'imap_port': 993,
        'smtp_port': 587,
        'ssl_required': True})

    # Gmail accounts don't expose a `server_settings` attribute
    api_client = new_api_client(db, gmail_account.namespace)
    resp_data = api_client.get_data('/account/?view=expanded')
    assert resp_data['provider'] == 'gmail'
    assert 'server_settings' not in resp_data
コード例 #3
0
ファイル: test_account.py プロジェクト: ivicac/sync-engine
def test_account_repr_for_new_account(db):
    account = add_fake_yahoo_account(db.session)

    # Sync for the account has not started yet.
    assert account.sync_state is None

    # However the API-returned account object has `sync_state=running`
    # so API clients can do the right thing.
    api_client = new_api_client(db, account.namespace)
    resp_data = api_client.get_data("/account")
    assert resp_data["id"] == account.namespace.public_id
    assert resp_data["sync_state"] == "running"

    # Verify other sync_states are not masked.
    account.sync_state = "invalid"
    db.session.commit()

    api_client = new_api_client(db, account.namespace)
    resp_data = api_client.get_data("/account")
    assert resp_data["id"] == account.namespace.public_id
    assert resp_data["sync_state"] == "invalid"
コード例 #4
0
def test_account_repr_for_new_account(db):
    account = add_fake_yahoo_account(db.session)

    # Sync for the account has not started yet.
    assert account.sync_state is None

    # However the API-returned account object has `sync_state=running`
    # so API clients can do the right thing.
    api_client = new_api_client(db, account.namespace)
    resp_data = api_client.get_data('/account')
    assert resp_data['id'] == account.namespace.public_id
    assert resp_data['sync_state'] == 'running'

    # Verify other sync_states are not masked.
    account.sync_state = 'invalid'
    db.session.commit()

    api_client = new_api_client(db, account.namespace)
    resp_data = api_client.get_data('/account')
    assert resp_data['id'] == account.namespace.public_id
    assert resp_data['sync_state'] == 'invalid'