コード例 #1
0
ファイル: test_views.py プロジェクト: scooley/osf.io
 def test_dropbox_folder_list_folders_only(self):
     with patch_client('website.addons.dropbox.model.DropboxClient'):
         url = self.project.api_url_for('dropbox_folder_list')
         res = self.app.get(url, auth=self.user.auth)
         contents = mock_client.metadata('', list=True)['contents']
         expected = [each for each in contents if each['is_dir']]
         assert_equal(len(res.json), len(expected))
コード例 #2
0
 def test_get_revisions(self):
     with patch_client('website.addons.dropbox.views.crud.get_node_addon_client'):
         path = 'foo.rst'
         url = self.project.api_url_for('dropbox_get_revisions', path=path)
         res = self.app.get(url, auth=self.user.auth)
         json_data = res.json
         result = json_data['result']
         expected = [
             rev for rev in mock_responses['revisions']
             if not rev.get('is_deleted')
         ]
         assert_equal(len(result), len(expected))
         for each in result:
             download_link = each['download']
             assert_equal(
                 download_link,
                 web_url_for(
                     'dropbox_download',
                     pid=self.project._primary_key,
                     path=path, rev=each['rev']
                 )
             )
             view_link = each['view']
             assert_equal(
                 view_link,
                 web_url_for(
                     'dropbox_view_file',
                     pid=self.project._primary_key,
                     path=path, rev=each['rev']
                 )
             )
コード例 #3
0
ファイル: test_views.py プロジェクト: mauromsl/osf.io
 def test_dropbox_folder_list_folders_only(self):
     with patch_client('website.addons.dropbox.views.DropboxClient'):
         url = self.project.api_url_for('dropbox_folder_list')
         res = self.app.get(url, auth=self.user.auth)
         contents = mock_client.metadata('', list=True)['contents']
         expected = [each for each in contents if each['is_dir']]
         assert_equal(len(res.json), len(expected))
コード例 #4
0
 def test_dropbox_hgrid_data_contents_folders_only(self):
     with patch_client('website.addons.dropbox.views.hgrid.get_node_client'):
         url = api_url_for('dropbox_hgrid_data_contents',
             pid=self.project._primary_key, foldersOnly=True)
         res = self.app.get(url, auth=self.user.auth)
         contents = mock_client.metadata('', list=True)['contents']
         expected = [each for each in contents if each['is_dir']]
         assert_equal(len(res.json), len(expected))
コード例 #5
0
 def test_dropbox_hgrid_data_contents_include_root(self, mock_metadata):
     with patch_client('website.addons.dropbox.views.hgrid.get_node_client'):
         url = api_url_for('dropbox_hgrid_data_contents',
             pid=self.project._primary_key, includeRoot=1)
         res = self.app.get(url, auth=self.user.auth)
         contents = mock_client.metadata('', list=True)['contents']
         assert_equal(len(res.json), len(contents) + 1)
         first_elem = res.json[0]
         assert_equal(first_elem['path'], '/')
コード例 #6
0
ファイル: test_views.py プロジェクト: lbanner/osf.io
 def test_dropbox_hgrid_data_contents_if_folder_is_none_and_folders_only(self):
     with patch_client('website.addons.dropbox.views.hgrid.get_node_client'):
         self.node_settings.folder = None
         self.node_settings.save()
         url = self.project.api_url_for('dropbox_hgrid_data_contents', foldersOnly=True)
         res = self.app.get(url, auth=self.user.auth)
         contents = mock_client.metadata('', list=True)['contents']
         expected = [each for each in contents if each['is_dir']]
         assert_equal(len(res.json), len(expected))
コード例 #7
0
ファイル: test_views.py プロジェクト: ubiquitypress/osf.io
 def test_dropbox_folder_list_if_folder_is_none_and_folders_only(self):
     with patch_client('website.addons.dropbox.views.DropboxClient'):
         self.node_settings.folder = None
         self.node_settings.save()
         url = self.project.api_url_for('dropbox_folder_list')
         res = self.app.get(url, auth=self.user.auth)
         contents = mock_client.metadata('', list=True)['contents']
         expected = [each for each in contents if each['is_dir']]
         assert_equal(len(res.json), len(expected))
コード例 #8
0
ファイル: test_views.py プロジェクト: scooley/osf.io
    def test_dropbox_folder_list_include_root(self, mock_metadata):
        with patch_client('website.addons.dropbox.model.DropboxClient'):
            url = self.project.api_url_for('dropbox_folder_list')

            res = self.app.get(url, auth=self.user.auth)
            contents = mock_client.metadata('', list=True)['contents']
            assert_equal(len(res.json), 1)
            assert_not_equal(len(res.json), len(contents))
            first_elem = res.json[0]
            assert_equal(first_elem['path'], '/')
コード例 #9
0
ファイル: test_views.py プロジェクト: mauromsl/osf.io
    def test_dropbox_folder_list_include_root(self, mock_metadata):
        with patch_client('website.addons.dropbox.views.DropboxClient'):
            url = self.project.api_url_for('dropbox_folder_list')

            res = self.app.get(url, auth=self.user.auth)
            contents = mock_client.metadata('', list=True)['contents']
            assert_equal(len(res.json), 1)
            assert_not_equal(len(res.json), len(contents))
            first_elem = res.json[0]
            assert_equal(first_elem['path'], '/')
コード例 #10
0
 def test_dropbox_delete_file_adds_log(self):
     with patch_client('website.addons.dropbox.views.crud.get_node_addon_client'):
         path = 'foo'
         url = self.project.api_url_for('dropbox_delete_file', path=path)
         self.app.delete(url, auth=self.user.auth)
         self.project.reload()
         last_log = self.project.logs[-1]
         assert_equal(last_log.action, 'dropbox_' + NodeLog.FILE_REMOVED)
         params = last_log.params
         assert_in('project', params)
         assert_in('node', params)
         assert_equal(params['path'], path)
コード例 #11
0
ファイル: test_views.py プロジェクト: mauromsl/osf.io
 def test_dropbox_folder_list(self):
     with patch_client('website.addons.dropbox.views.DropboxClient'):
         url = self.project.api_url_for(
             'dropbox_folder_list',
             folderId='/',
         )
         res = self.app.get(url, auth=self.user.auth)
         contents = [x for x in mock_client.metadata('', list=True)['contents'] if x['is_dir']]
         assert_equal(len(res.json), len(contents))
         first = res.json[0]
         assert_in('kind', first)
         assert_equal(first['path'], contents[0]['path'])
コード例 #12
0
 def test_dropbox_hgrid_data_contents(self):
     with patch_client('website.addons.dropbox.views.hgrid.get_node_client'):
         url = api_url_for(
             'dropbox_hgrid_data_contents',
             path=self.node_settings.folder,
             pid=self.project._primary_key,
         )
         res = self.app.get(url, auth=self.user.auth)
         contents = mock_client.metadata('', list=True)['contents']
         assert_equal(len(res.json), len(contents))
         first = res.json[0]
         assert_in('kind', first)
         assert_equal(first['path'], contents[0]['path'])
コード例 #13
0
ファイル: test_views.py プロジェクト: scooley/osf.io
 def test_dropbox_folder_list(self):
     with patch_client('website.addons.dropbox.model.DropboxClient'):
         url = self.project.api_url_for(
             'dropbox_folder_list',
             folder_id='/',
         )
         res = self.app.get(url, auth=self.user.auth)
         contents = [
             x for x in mock_client.metadata('', list=True)['contents']
             if x['is_dir']
         ]
         assert_equal(len(res.json), len(contents))
         first = res.json[0]
         assert_in('kind', first)
         assert_equal(first['path'], contents[0]['path'])