<commit_before># -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

from datetime import timedelta
import os
import json

from eve.utils import config
from eve.versioning import versioned_id_field
from apps.archive.archive import SOURCE as ARCHIVE
from apps.validators import ValidatorsPopulateCommand

from superdesk.tests import TestCase
from apps.publish import init_app, publish_queue, RemoveExpiredPublishContent
from apps.legal_archive import LEGAL_ARCHIVE_NAME, LEGAL_ARCHIVE_VERSIONS_NAME, LEGAL_PUBLISH_QUEUE_NAME, \
    LEGAL_FORMATTED_ITEM_NAME
from superdesk.utc import utcnow
from superdesk import get_resource_service
import superdesk


class ArchivePublishTestCase(TestCase):
    def init_data(self):
        self.subscribers = [{'_id': '1', 'name': 'sub1', 'is_active': True, 'destinations': [{
            'name': 'dest1',
            'delivery_type': 'ftp',
            'config': {'address': '127.0.0.1', 'username': 'test'}}]},
                            {'_id': '2', 'name': 'sub1', 'is_active': True, 'destinations': [{
                                'name': 'dest2',
                                'delivery_type': 'file copy',
                                'config': {'address': '/share/copy'}}, {
                                'name': 'dest3',
                                'delivery_type': 'Email',
                                'config': {'address': '<EMAIL>'}}]}]

        self.output_channels = [{'_id': '1', 'name': 'oc1', 'is_active': True, 'format': 'nitf', 'destinations': ['1']},
                                {'_id': '2', 'name': 'oc2', 'is_active': False, 'format': 'nitf',
                                 'destinations': ['1', '2']},
                                {'_id': '3', 'name': 'oc3', 'is_active': True, 'format': 'anpa', 'destinations': ['2']},
                                {'_id': '4', 'name': 'oc4', 'is_active': True,
                                 'is_digital': True, 'format': 'nitf', 'destinations': ['2']}]

        self.destination_groups = [{'_id': '1', 'name': 'dg1'},
                                   {'_id': '2', 'name': 'dg2', 'destination_groups': ['1']},
                                   {'_id': '3', 'name': 'dg3',
                                    'output_channels': [{'channel': '1', 'selector_codes': ['A', 'B']}]},
                                   {'_id': '4', 'name': 'dg4',
                                    'output_channels': [{'channel': '1', 'selector_codes': ['Y']},
                                                        {'channel': '2', 'selector_codes': ['X', 'B']},
                                                        {'channel': '4'}]},
                                   {'_id': '5', 'name': 'dg5',
                                    'output_channels': [{'channel': '2', 'selector_codes': ['A']},
                                                        {'channel': '3', 'selector_codes': ['X', 'y']}]}]

        self.articles = [{'guid': 'tag:localhost:2015:69b961ab-2816-4b8a-a584-a7b402fed4f9',
                          '_id': '1',
                          'type': 'text',
                          'last_version': 3,
                          config.VERSION: 4,
                          'body_html': 'Test body',
                          'destination_groups': ['4'],
                          'urgency': 4,
                          'headline': 'Two students missing',
                          'pubstatus': 'usable',<commit_msg>Fixing flake8 errors.<commit_after># -*- coding: utf-8; -*-
#
# This file is part of Superdesk.
#
# Copyright 2013, 2014 Sourcefabric z.u. and contributors.
#
# For the full copyright and license information, please see the
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

from datetime import timedelta
import os
import json

from eve.utils import config
from eve.versioning import versioned_id_field
from apps.archive.archive import SOURCE as ARCHIVE
from apps.validators import ValidatorsPopulateCommand

from superdesk.tests import TestCase
from apps.publish import init_app, publish_queue, RemoveExpiredPublishContent
from apps.legal_archive import LEGAL_ARCHIVE_NAME, LEGAL_ARCHIVE_VERSIONS_NAME, LEGAL_PUBLISH_QUEUE_NAME, \
    LEGAL_FORMATTED_ITEM_NAME
from superdesk.utc import utcnow
from superdesk import get_resource_service
import superdesk


class ArchivePublishTestCase(TestCase):
    def init_data(self):
        self.subscribers = [{'_id': '1', 'name': 'sub1', 'is_active': True, 'destinations': [{
            'name': 'dest1',
            'delivery_type': 'ftp',
            'config': {'address': '127.0.0.1', 'username': 'test'}}]},
            {'_id': '2', 'name': 'sub1', 'is_active': True,
             'destinations': [{'name': 'dest2',
                               'delivery_type': 'file copy',
                               'config': {'address': '/share/copy'}},
                              {'name': 'dest3',
                               'delivery_type': 'Email',
                               'config': {'address': '<EMAIL>'}}]}]

        self.output_channels = [{'_id': '1', 'name': 'oc1', 'is_active': True, 'format': 'nitf', 'destinations': ['1']},
                                {'_id': '2', 'name': 'oc2', 'is_active': False, 'format': 'nitf',
                                 'destinations': ['1', '2']},
                                {'_id': '3', 'name': 'oc3', 'is_active': True, 'format': 'anpa', 'destinations': ['2']},
                                {'_id': '4', 'name': 'oc4', 'is_active': True,
                                 'is_digital': True, 'format': 'nitf', 'destinations': ['2']}]

        self.destination_groups = [{'_id': '1', 'name': 'dg1'},
                                   {'_id': '2', 'name': 'dg2', 'destination_groups': ['1']},
                                   {'_id': '3', 'name': 'dg3',
                                    'output_channels': [{'channel': '1', 'selector_codes': ['A', 'B']}]},
                                   {'_id': '4', 'name': 'dg4',
                                    'output_channels': [{'channel': '1', 'selector_codes': ['Y']},
                                                        {'channel': '2', 'selector_codes': ['X', 'B']},
                                                        {'channel': '4'}]},
                                   {'_id': '5', 'name': 'dg5',
                                    'output_channels': [{'channel': '2', 'selector_codes': ['A']},
                                                        {'channel': '3', 'selector_codes': ['X', 'y']}]}]

        self.articles = [{'guid': 'tag:localhost:2015:69b961ab-2816-4b8a-a584-a7b402fed4f9',
                          '_id': '1',
                          'type': 'text',
                          'last_version': 3,
                          config.VERSION: 4,
                          'body_html': 'Test body',
                          'destination_groups': ['4'],
                          'urgency': 4,
                          'headline': 'Two students missing',
                          'pubstatus': 'usable',
{'fraction_non_alphanumeric': 0.1601790316017903, 'fraction_numerical': 0.022107690221076903, 'mean_word_length': 1.623265741728922, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1074930', 'n_tokens_mistral': 2133, 'n_tokens_neox': 2010, 'n_words': 507}