# Path: adsft/tasks.py
# def task_check_if_extract(message):
# def task_extract(message):
#     def task_extract_grobid(message):
# def task_output_results(msg):
# def task_identify_facilities(message):
# 
# Path: adsft/reader.py
# def read_file(input_filename, json_format=True):
# def read_content(payload_dictionary):
# 
# Path: adsft/tests/test_base.py
# def build_links(test_name):
#     def setUp(self):
#     def tearDown(self):
#     def setUp(self):
#     def tearDown(self):
#     def helper_get_details(self, test_publish):
#     def calculate_expected_folders(self, full_text_links):
#     def clean_up_path(self, paths):
# class TestUnit(unittest.TestCase):
# class TestGeneric(unittest.TestCase):
#         PROJ_HOME = self.app.conf['PROJ_HOME']


import unittest
import os
import sys
import json
import httpretty
import pdb
from mock import patch
from adsft import tasks, reader
from adsft.tests import test_base
from datetime import datetime
from mock import patch
        from run import read_links_from_file
        self.assertEqual(
            len(records.bibcode), self.nor,
            'The number of records should match'
            ' the number of lines. It does not: '
            '{0} [{1}]'.format(len(records.bibcode), self.nor))

        self.assertTrue(len(records.payload) == 6)

        # Make the fake data to use
        if not os.path.exists(self.meta_path):
            os.makedirs(self.meta_path)

        # Call the task to check if it should be extracted but mock the extraction task
        with patch.object(tasks.task_extract, 'delay', return_value=None) as task_extract:
            extraction_arguments_set = []
            expected_update = 'NOT_EXTRACTED_BEFORE'
            for message in records.payload:
                tasks.task_check_if_extract(message)
                self.assertTrue(task_extract.called)
                actual = task_extract.call_args[0][0]
                self.assertEqual(actual['UPDATE'], expected_update,
                        'This should be %s, but is in fact: {0}'
                        .format(expected_update, actual['UPDATE']))
                extraction_arguments_set.append(actual)

        with patch.object(tasks.task_output_results, 'delay', return_value=None) as task_output_results:
            with patch.object(tasks.task_identify_facilities, 'delay', return_value=None) as task_identify_facilities:
                # Now we do call the extraction task with the proper arguments
                for arguments in extraction_arguments_set:
                    #if arguments['ft_source'].endswith('.pdf') is False:

# Path: adsft/tasks.py
# def task_check_if_extract(message):
# def task_extract(message):
#     def task_extract_grobid(message):
# def task_output_results(msg):
# def task_identify_facilities(message):
# 
# Path: adsft/reader.py
# def read_file(input_filename, json_format=True):
# def read_content(payload_dictionary):
# 
# Path: adsft/tests/test_base.py
# def build_links(test_name):
#     def setUp(self):
#     def tearDown(self):
#     def setUp(self):
#     def tearDown(self):
#     def helper_get_details(self, test_publish):
#     def calculate_expected_folders(self, full_text_links):
#     def clean_up_path(self, paths):
# class TestUnit(unittest.TestCase):
# class TestGeneric(unittest.TestCase):
#         PROJ_HOME = self.app.conf['PROJ_HOME']


# Path: adsft/tests/test_full_range_of_formats.py
import unittest
import os
import sys
import json
import httpretty
import pdb
from mock import patch
from adsft import tasks, reader
from adsft.tests import test_base
from datetime import datetime
from mock import patch
        from run import read_links_from_file

        self.assertEqual(
            len(records.bibcode), self.nor,
            'The number of records should match'
            ' the number of lines. It does not: '
            '{0} [{1}]'.format(len(records.bibcode), self.nor))

        self.assertTrue(len(records.payload) == 6)

        # Make the fake data to use
        if not os.path.exists(self.meta_path):
            os.makedirs(self.meta_path)

        # Call the task to check if it should be extracted but mock the extraction task
        with patch.object(tasks.task_extract, 'delay', return_value=None) as task_extract:
            extraction_arguments_set = []
            expected_update = 'NOT_EXTRACTED_BEFORE'
            for message in records.payload:
                tasks.task_check_if_extract(message)
                self.assertTrue(task_extract.called)
                actual = task_extract.call_args[0][0]
                self.assertEqual(actual['UPDATE'], expected_update,
                        'This should be %s, but is in fact: {0}'
                        .format(expected_update, actual['UPDATE']))
                extraction_arguments_set.append(actual)

        with patch.object(tasks.task_output_results, 'delay', return_value=None) as task_output_results:
            with patch.object(tasks.task_identify_facilities, 'delay', return_value=None) as task_identify_facilities:
                # Now we do call the extraction task with the proper arguments
                for arguments in extraction_arguments_set:
                    #if arguments['ft_source'].endswith('.pdf') is False:

                    tasks.task_extract(arguments)