# 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 time
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
            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) == 1)

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

        test_meta_content = {
            'index_date': datetime.utcnow().isoformat()+'Z',
            'bibcode': self.bibcode,
            'provider': self.provider,
            'ft_source': self.ft_source
        }

        with open(self.test_expected.replace('meta.json', 'fulltext.txt.gz'), 'w')\
                as test_full_text_file:
            test_full_text_file.write('Full text content')

        time.sleep(2)
        with open(self.test_expected, 'w') as test_meta_file:
            json.dump(test_meta_content, test_meta_file)


        # 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:
            message = records.payload[0]

# 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_stale_content.py
import unittest
import os
import sys
import json
import time
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

            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) == 1)

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

        test_meta_content = {
            'index_date': datetime.utcnow().isoformat()+'Z',
            'bibcode': self.bibcode,
            'provider': self.provider,
            'ft_source': self.ft_source
        }

        with open(self.test_expected.replace('meta.json', 'fulltext.txt.gz'), 'w')\
                as test_full_text_file:
            test_full_text_file.write('Full text content')

        time.sleep(2)
        with open(self.test_expected, 'w') as test_meta_file:
            json.dump(test_meta_content, test_meta_file)


        # 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:
            message = records.payload[0]

            tasks.task_check_if_extract(message)