class TestApplicator(unittest.TestCase):
    def setUp(self):
        self.a = EADDir(input_dir=r'test_files')
        self.test_output_dir = r"test_files\output"

    def _method_for_testing_write(self, ead):
        texts = ead.tree.xpath("//text")
        for text in texts:
            text.text = "yo"

    def _method_for_testing_characterize(self, ead):
        results = []
        texts = ead.tree.xpath("//text")
        for text in texts:
            results.append(text.text)
        return results

    def test_ead_list(self):
        self.assertEquals(self.a.ead_files, ['ead_appended.xml', 'ead_messy.xml', 'ead_pretty.xml'])

    def test_characterize_directory(self):
        intended_results = [['text'], ['text'], ['text']]
        self.assertEquals(self.a.characterize_dir(function=self._method_for_testing_characterize), intended_results)

    def test_apply_to_directory(self):
        self.a.apply_function_to_dir(function=self._method_for_testing_write, output_dir=self.test_output_dir)

        b = EADDir(self.test_output_dir)
        intended_results = [['yo'], ['yo'], ['yo']]
        self.assertEquals(b.characterize_dir(self._method_for_testing_characterize), intended_results)

        for ead in os.listdir(self.test_output_dir):
            os.remove(os.path.join(self.test_output_dir, ead))
    def test_apply_to_directory(self):
        self.a.apply_function_to_dir(function=self._method_for_testing_write, output_dir=self.test_output_dir)

        b = EADDir(self.test_output_dir)
        intended_results = [['yo'], ['yo'], ['yo']]
        self.assertEquals(b.characterize_dir(self._method_for_testing_characterize), intended_results)

        for ead in os.listdir(self.test_output_dir):
            os.remove(os.path.join(self.test_output_dir, ead))
 def setUp(self):
     self.a = EADDir(input_dir=r'test_files')
     self.test_output_dir = r"test_files\output"
def add_aspace_ids_to_all_agents_in_dir(name_to_id_map, path_to_eads):
    ead_dir = EADDir(input_dir=path_to_eads)
    ead_dir.apply_function_to_dir(function=add_aspace_ids_to_agents, var1=name_to_id_map, output_dir=path_to_eads)