<commit_before># -*- coding: utf-8 -*-
"""Factory boy factories for the Box addon."""
import mock
from datetime import datetime

from framework.auth import Auth

from factory import SubFactory, Sequence, post_generation
from tests.factories import ModularOdmFactory, UserFactory, ProjectFactory

from website.addons.box.model import (
    BoxUserSettings, BoxNodeSettings, BoxFile
)

# TODO(sloria): make an abstract UserSettingsFactory that just includes the owner field
class BoxUserSettingsFactory(ModularOdmFactory):
    FACTORY_FOR = BoxUserSettings

    owner = SubFactory(UserFactory)
    access_token = Sequence(lambda n: 'abcdef{0}'.format(n))
    last_refreshed = datetime.utcnow()


class BoxNodeSettingsFactory(ModularOdmFactory):
    FACTORY_FOR = BoxNodeSettings

    owner = SubFactory(ProjectFactory)
    user_settings = SubFactory(BoxUserSettingsFactory)
    with mock.patch('website.addons.box.model.BoxNodeSettings.folder') as mock_folder:
        mock_folder.__get__ = mock.Mock(return_value='Camera Uploads')


class BoxFileFactory(ModularOdmFactory):
    FACTORY_FOR = BoxFile

    node = SubFactory(ProjectFactory)
    path = 'foo.txt'
<commit_msg>Update factories<commit_after># -*- coding: utf-8 -*-
"""Factory boy factories for the Box addon."""
import mock
from datetime import datetime

from framework.auth import Auth

from factory import SubFactory, Sequence, post_generation
from tests.factories import ModularOdmFactory, UserFactory, ProjectFactory

from website.addons.box.model import (
    BoxOAuthSettings, BoxUserSettings,
    BoxNodeSettings, BoxFile
)

# TODO(sloria): make an abstract UserSettingsFactory that just includes the owner field

class BoxOAuthSettingsFactory(ModularOdmFactory):
    FACTORY_FOR = BoxOAuthSettings

    username = 'Den'
    user_id = 'b4rn311'
    expires_at = datetime(2045, 1, 1)
    access_token = Sequence(lambda n: 'abcdef{0}'.format(n))
    refresh_token = Sequence(lambda n: 'abcdef{0}'.format(n))


class BoxUserSettingsFactory(ModularOdmFactory):
    FACTORY_FOR = BoxUserSettings

    owner = SubFactory(UserFactory)
    oauth_settings = SubFactory(BoxOAuthSettingsFactory)


class BoxNodeSettingsFactory(ModularOdmFactory):
    FACTORY_FOR = BoxNodeSettings

    owner = SubFactory(ProjectFactory)
    user_settings = SubFactory(BoxUserSettingsFactory)
    with mock.patch('website.addons.box.model.BoxNodeSettings.folder') as mock_folder:
        mock_folder.__get__ = mock.Mock(return_value='Camera Uploads')


class BoxFileFactory(ModularOdmFactory):
    FACTORY_FOR = BoxFile

    node = SubFactory(ProjectFactory)
    path = 'foo.txt'

{'fraction_non_alphanumeric': 0.08476517754868271, 'fraction_numerical': 0.0057273768613974796, 'mean_word_length': 5.093023255813954, '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': '7134611', 'n_tokens_mistral': 790, 'n_tokens_neox': 759, 'n_words': 186}