示例#1
0
 def test_connect_dropbox_success(self):
     try:
         db_client = listsdotmd.connect_to_dropbox()
     except ValueError:
         self.fail(msg="Bad token")
     try:
         account = db_client.account_info()
     except ErrorResponse as e:
         print e
         self.fail()
     self.assertIn('uid', account)
示例#2
0
 def test_connect_dropbox_fail(self):
     bad_token = 'rawr'
     db_client = listsdotmd.connect_to_dropbox(token=bad_token)
     with self.assertRaises(ErrorResponse):
         db_client.account_info()
示例#3
0
文件: web.py 项目: jeffroche/lists.md
app = Flask(__name__)

if not HEROKU:
    app.debug = True
    r = redis.StrictRedis(host="localhost", port=6379, db=0)
else:
    redis_url = os.getenv("REDISTOGO_URL", "redis://*****:*****@app.route("/")
def list_lists():
    """Displays a list of the lists contained in DROPBOX_LIST_FOLDER"""
    try:
        new_hash = listsdotmd.get_folder_hash(db_client, DROPBOX_LIST_FOLDER)
    except ErrorResponse:
        abort(404)
        app.logger.error("Couldn't get index hash from Dropbox")
    index_in_redis = r.get("index")
    if index_in_redis:
        index_in_redis = json.loads(index_in_redis)
    if not index_in_redis or "hash" not in index_in_redis or (new_hash != index_in_redis["hash"]):
        all_lists = listsdotmd.index_lists(db_client, DROPBOX_LIST_FOLDER)