<commit_before>#!/usr/bin/env python
# encoding: utf-8

import httplib as http
import mock
from nose.tools import *  # noqa

from website.addons.base import testing
from website.addons.figshare.model import FigshareClient
from website.addons.figshare.tests.utils import FigshareAddonTestCase

class TestAuthViews(FigshareAddonTestCase, testing.views.OAuthAddonAuthViewsTestCaseMixin):
    pass

class TestConfigViews(FigshareAddonTestCase, testing.views.OAuthAddonConfigViewsTestCaseMixin):

    ## Overrides

    @mock.patch.object(FigshareClient, 'get_folders')
    @mock.patch.object(FigshareClient, 'get_linked_folder_info')
    def test_folder_list(self, mock_about, mock_folders):
        mock_folders.return_value = [{'label': 'Memes', 'value': 'fileset_009001'}]
        mock_about.return_value = {'path': 'fileset', 'name': 'Memes', 'id': '009001'}
        super(TestConfigViews, self).test_folder_list()

    @mock.patch.object(FigshareClient, 'get_linked_folder_info')
    def test_set_config(self, mock_about):
        # Changed from super for mocking and log action name
        mock_about.return_value = {'path': 'fileset', 'name': 'Memes', 'id': '009001'}
        self.node_settings.set_auth(self.external_account, self.user)
        url = self.project.api_url_for('{0}_set_config'.format(self.ADDON_SHORT_NAME))
        res = self.app.put_json(url, {
            'selected': self.folder
        }, auth=self.user.auth)<commit_msg>Update test based on folder meta convention<commit_after>#!/usr/bin/env python
# encoding: utf-8

import httplib as http
import mock
from nose.tools import *  # noqa

from website.addons.base import testing
from website.addons.figshare.model import FigshareClient
from website.addons.figshare.tests.utils import FigshareAddonTestCase

class TestAuthViews(FigshareAddonTestCase, testing.views.OAuthAddonAuthViewsTestCaseMixin):
    pass

class TestConfigViews(FigshareAddonTestCase, testing.views.OAuthAddonConfigViewsTestCaseMixin):

    ## Overrides

    @mock.patch.object(FigshareClient, 'get_folders')
    @mock.patch.object(FigshareClient, 'get_linked_folder_info')
    def test_folder_list(self, mock_about, mock_folders):
        mock_folders.return_value = [{'path': 'fileset', 'name': 'Memes', 'id': '009001'}]
        mock_about.return_value = {'path': 'fileset', 'name': 'Memes', 'id': '009001'}
        super(TestConfigViews, self).test_folder_list()

    @mock.patch.object(FigshareClient, 'get_linked_folder_info')
    def test_set_config(self, mock_about):
        # Changed from super for mocking and log action name
        mock_about.return_value = {'path': 'fileset', 'name': 'Memes', 'id': '009001'}
        self.node_settings.set_auth(self.external_account, self.user)
        url = self.project.api_url_for('{0}_set_config'.format(self.ADDON_SHORT_NAME))
        res = self.app.put_json(url, {
            'selected': self.folder
        }, auth=self.user.auth)
{'fraction_non_alphanumeric': 0.1194947080914988, 'fraction_numerical': 0.013656538067599864, 'mean_word_length': 4.580952380952381, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1680355', 'n_tokens_mistral': 965, 'n_tokens_neox': 929, 'n_words': 179}