Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rearranged some of the code to make more sense.

  • Loading branch information...
commit 492f9756535fbe3f5e2e88f091fdca032f902286 1 parent 5399cf0
@Ronnie76er authored
Showing with 34 additions and 13 deletions.
  1. +22 −11 plugins/DropboxOfficialApi.py
  2. +12 −2 test/dropboxtest.py
View
33 plugins/DropboxOfficialApi.py
@@ -1,13 +1,22 @@
-from BasePluginApi import BasePluginApi
from dropbox import auth, client
-class DropboxOfficialApi(BasePluginApi):
+class DropboxOfficialApi():
- def __init__(self, configFilename):
- self.configFilename = configFilename
+ server = 'api.dropbox.com'
+ content_server = 'api-content.dropbox.com'
+ port = 80
+
+ request_token_url = 'https://api.dropbox.com/0/oauth/request_token'
+ access_token_url = 'https://api.dropbox.com/0/oauth/access_token'
+ authorization_url = 'https://www.dropbox.com/0/oauth/authorize'
+ trusted_access_token_url = 'https://api.dropbox.com/0/token'
+
+ def __init__(self, consumer_key, consumer_secret, config):
+ self.consumer_key = consumer_key
+ self.consumer_secret = consumer_secret
+ self.config = config
def authenticate(self):
- self.config = auth.Authenticator.load_config(self.configFilename)
authenticator = auth.Authenticator(self.config)
token = authenticator.obtain_request_token()
@@ -15,16 +24,17 @@ def authenticate(self):
tmp = raw_input("Hit enter when you've authorized it")
- access_token = authenticator.obtain_access_token(token, self.config['verifier'])
-
- print access_token
+ access_token = authenticator.obtain_access_token(token, None)
- self.client = client.DropboxClient(self.config['server'],
- self.config['content_server'],
- self.config['port'],
+ self.client = client.DropboxClient(self.server,
+ self.content_server,
+ self.port,
authenticator,
access_token)
+ def requestAuthorization(self):
+ print 'Something'
+
def sendFile(self, filename):
f = open(filename)
resp = self.client.put_file('dropbox', '/', f)
@@ -38,4 +48,5 @@ def getFile(self, filename):
def deleteFile(self, filename):
resp = self.client.file_delete('dropbox', '/' + filename)
return resp
+
View
14 test/dropboxtest.py
@@ -1,11 +1,20 @@
import unittest
from pythoncloudfilestorage.client.client import FileStorageClient
from pythoncloudfilestorage.plugins.DropboxOfficialApi import DropboxOfficialApi
+from ConfigParser import SafeConfigParser
class TestDropBox(unittest.TestCase):
+ filename = 'testing.ini'
+
def testApi(self):
- api = DropboxOfficialApi('testing.ini')
+
+ config = SafeConfigParser()
+ configFile = open(self.filename, 'r')
+ config.readfp(configFile)
+ configDict = dict(config.items('auth'))
+
+ api = DropboxOfficialApi(configDict['consumer_key'], configDict['consumer_secret'], configDict)
myClient = FileStorageClient(api)
@@ -29,4 +38,5 @@ def testApi(self):
if __name__ == '__main__':
- unittest.main()
+ suite = unittest.TestLoader().loadTestsFromTestCase(TestDropBox)
+ unittest.TextTestRunner(verbosity=2).run(suite)
Please sign in to comment.
Something went wrong with that request. Please try again.