예제 #1
0
파일: tests.py 프로젝트: jeffroche/dropcms
 def test_root_index(self, patched_get_file, patched_metadata):
     """Tests that the root folder index file is loaded for a folder
     or generated properly based on the files in the folder
     """
     dbc = dropcms.DropCMS('token', '/')
     index_file, file_list = dbc.get_root_index()
     self.assertIsNotNone(index_file)
     self.assertEqual(file_list, ['One Pagers', 'lists'])
예제 #2
0
파일: tests.py 프로젝트: jeffroche/dropcms
 def test_folder_index(self, patched_get_file, patched_metadata):
     """Tests that the folder index file is loaded for a folder
     or generated properly based on the files in the folder
     """
     dbc = dropcms.DropCMS('token', '/')
     expected_files = ['cocktails', 'bars', 'books', 'brooklyn']
     index_file, file_list = dbc.get_folder_index('lists')
     self.assertIsNone(index_file)
     self.assertEqual(file_list, expected_files)
예제 #3
0
파일: views.py 프로젝트: jeffroche/dropcms
def get_or_create_cms():
    # This is ugly but Flask won't let you access the application
    # context until you are in an app function
    global cms
    if cms is None:
        # http://stackoverflow.com/questions/13454507/is-it-possible-to-import-flask-configuration-values-in-modules-without-circular
        DROPBOX_ACCESS_TOKEN = current_app.config.get('DROPBOX_ACCESS_TOKEN')
        DROPBOX_ROOT_FOLDER = current_app.config.get('DROPBOX_ROOT_FOLDER')
        cms = dropcms.DropCMS(DROPBOX_ACCESS_TOKEN, DROPBOX_ROOT_FOLDER)
    return cms
예제 #4
0
파일: tests.py 프로젝트: jeffroche/dropcms
    def test_structure(self, patched_metadata):
        """Tests that the list of folders is returned by
        ``get_content_structure``
        """
        dbc = dropcms.DropCMS('token', '/')
        content = dbc.structure()
        folders = content['folders']

        self.assertEqual(len(folders), 2)
        self.assertIn('lists', folders.keys())
        self.assertIn('One Pagers', folders.keys())
        self.assertEqual(len(folders['lists']['pages']), 4)
        self.assertEqual(len(folders['One Pagers']['pages']), 4)
        self.assertIn('brooklyn', folders['lists']['pages'].keys())
        self.assertIn('python', folders['One Pagers']['pages'].keys())
        self.assertNotIn('windows.txt', folders['One Pagers']['pages'].keys())
예제 #5
0
파일: tests.py 프로젝트: jeffroche/dropcms
 def test_load_file(self, patched_get_file, patched_metadata):
     """Tests loading a file from dropbox
     """
     dbc = dropcms.DropCMS('token', '/')
     dbc.get_page('lists', 'brooklyn')
     patched_get_file.assert_called_with('/cms/lists/brooklyn.md')