Example #1
0
 def test_serialize_settings_helper_returns_correct_folder_info(self):
     result = serialize_settings(self.node_settings,
                                 self.user,
                                 client=mock_client)
     folder = result['folder']
     assert_equal(folder['name'], self.node_settings.folder)
     assert_equal(folder['path'], self.node_settings.folder)
Example #2
0
 def test_serialize_settings_for_user_no_auth(self):
     no_addon_user = AuthUserFactory()
     result = serialize_settings(self.node_settings,
                                 no_addon_user,
                                 client=mock_client)
     assert_false(result['userIsOwner'])
     assert_false(result['userHasAuth'])
Example #3
0
 def test_serialize_settings_helper_returns_correct_auth_info(self):
     result = serialize_settings(self.node_settings,
                                 self.user,
                                 client=mock_client)
     assert_equal(result['nodeHasAuth'], self.node_settings.has_auth)
     assert_true(result['userHasAuth'])
     assert_true(result['userIsOwner'])
Example #4
0
 def test_serialize_settings_invalid_credentials(self, mock_account_info):
     mock_response = mock.Mock()
     mock_response.status = 401
     mock_account_info.side_effect = ErrorResponse(
         mock_response,
         "The given OAuth 2 access token doesn't exist or has expired.")
     result = serialize_settings(self.node_settings, self.user)
     assert_false(result['validCredentials'])
Example #5
0
    def test_dropbox_import_user_auth_returns_serialized_settings(self, mock_account_info):
        mock_account_info.return_value = {'display_name': 'Mr. Drop Box'}
        # Node does not have user settings
        self.node_settings.user_settings = None
        self.node_settings.save()
        url = api_url_for('dropbox_import_user_auth', pid=self.project._primary_key)
        res = self.app.put(url, auth=self.user.auth)
        self.project.reload()
        self.node_settings.reload()

        expected_result = serialize_settings(self.node_settings, self.user,
                                             client=mock_client)
        result = res.json['result']
        assert_equal(result, expected_result)
Example #6
0
    def test_serialize_settings_helper_returns_correct_urls(self):
        result = serialize_settings(self.node_settings, self.user, client=mock_client)
        urls = result['urls']

        assert_equal(urls['config'], self.project.api_url_for('dropbox_config_put'))
        assert_equal(urls['deauthorize'], self.project.api_url_for('dropbox_deauthorize'))
        assert_equal(urls['auth'], self.project.api_url_for('dropbox_oauth_start'))
        assert_equal(urls['importAuth'], self.project.api_url_for('dropbox_import_user_auth'))
        assert_equal(urls['files'], self.project.web_url_for('collect_file_trees'))
        # Includes endpoint for fetching folders only
        # NOTE: Querystring params are in camelCase
        assert_equal(urls['folders'],
            self.project.api_url_for('dropbox_hgrid_data_contents', root=1))
        assert_equal(urls['settings'], web_url_for('user_addons'))
Example #7
0
    def test_serialize_settings_helper_returns_correct_urls(self):
        result = serialize_settings(self.node_settings, self.user, client=mock_client)
        urls = result['urls']

        assert_equal(urls['config'], self.project.api_url_for('dropbox_config_put'))
        assert_equal(urls['deauthorize'], self.project.api_url_for('dropbox_deauthorize'))
        assert_equal(urls['auth'], self.project.api_url_for('dropbox_oauth_start'))
        assert_equal(urls['importAuth'], self.project.api_url_for('dropbox_import_user_auth'))
        assert_equal(urls['files'], self.project.web_url_for('collect_file_trees'))
        assert_equal(urls['share'], utils.get_share_folder_uri(self.node_settings.folder))
        # Includes endpoint for fetching folders only
        # NOTE: Querystring params are in camelCase
        assert_equal(urls['folders'],
            self.project.api_url_for('dropbox_hgrid_data_contents', foldersOnly=1, includeRoot=1))
        assert_equal(urls['settings'], web_url_for('user_addons'))
Example #8
0
 def test_serialize_settings_helper_returns_correct_folder_info(self):
     result = serialize_settings(self.node_settings, self.user, client=mock_client)
     folder = result['folder']
     assert_equal(folder['name'], 'Dropbox' + self.node_settings.folder)
     assert_equal(folder['path'], self.node_settings.folder)
Example #9
0
 def test_serialize_settings_invalid_credentials(self, mock_account_info):
     mock_response = mock.Mock()
     mock_response.status = 401
     mock_account_info.side_effect = ErrorResponse(mock_response, "The given OAuth 2 access token doesn't exist or has expired.")
     result = serialize_settings(self.node_settings, self.user)
     assert_false(result['validCredentials'])
Example #10
0
 def test_serialize_settings_valid_credentials(self, mock_account_info):
     mock_account_info.return_value = {'display_name': 'Mr. Drop Box'}
     result = serialize_settings(self.node_settings, self.user, client=mock_client)
     assert_true(result['validCredentials'])
Example #11
0
 def test_serialize_settings_for_user_no_auth(self):
     no_addon_user = AuthUserFactory()
     result = serialize_settings(self.node_settings, no_addon_user, client=mock_client)
     assert_false(result['userIsOwner'])
     assert_false(result['userHasAuth'])
Example #12
0
 def test_serialize_settings_helper_returns_correct_auth_info(self):
     result = serialize_settings(self.node_settings, self.user, client=mock_client)
     assert_equal(result['nodeHasAuth'], self.node_settings.has_auth)
     assert_true(result['userHasAuth'])
     assert_true(result['userIsOwner'])