def test_obtain_access_token(): config = test_config() dba = auth.Authenticator(config) req_token = dba.obtain_request_token() assert req_token and dba.oauth_request authorize_url = dba.build_authorize_url(req_token, callback="http://comback.com/") assert "comback" in authorize_url, "Should have the return address in it." authorize_url = dba.build_authorize_url(req_token) login_and_authorize(authorize_url, config) access_token = dba.obtain_access_token(req_token, config['verifier']) assert access_token assert dba.oauth_request assert access_token.key != req_token.key return access_token, dba
from nose.tools import * from dropbox import client, rest, auth from helpers import login_and_authorize import os import simplejson as json config = auth.Authenticator.load_config("config/testing.ini") dba = auth.Authenticator(config) print "CONFIG", config token = dba.obtain_request_token() login_and_authorize(dba.build_authorize_url(token), config) access_token = dba.obtain_access_token(token, config['verifier']) db_client = client.DropboxClient(config['server'], config['content_server'], 80, dba, access_token) CALLBACK_URL = 'http://printer.example.com/request_token_ready' RESOURCE_URL = 'http://' + config['server'] + '/0/oauth/echo' def test_delete(): db_client.file_delete("sandbox", "/tohere") return db_client def test_put_file(): for target in ["tests/file with spaces.txt", "tests/dropbox_tests/client_tests.py", ]: f = open(target) resp = db_client.put_file("sandbox", "/", f) print "BODY: ", resp.body