示例#1
0
 def test_index_lists(self):
     """Should return a list of the .md files in the folder"""
     db_client = MockDropboxClient()
     file_list = listsdotmd.index_lists(db_client, '/')
     _expected_list = [
         {'path': '/list1.md',
          'name': 'list1',
          'updated': 'Thu, 25 Aug 2011 00:03:15 +0000'},
         {'path': '/list2.md',
          'name': 'list2',
          'updated': 'Thu, 25 Aug 2011 00:03:15 +0000'}]
     self.assertEqual(file_list, _expected_list)
示例#2
0
文件: web.py 项目: jeffroche/lists.md
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)
        r.set("index", json.dumps({"data": all_lists, "hash": new_hash}))
    else:
        all_lists = index_in_redis["data"]
    return render_template("index.html", lists=all_lists)