<commit_before>import unittest
import os
import shutil
import threading
import logging

from lib.util import transfer_directory
from lib.events import Event_list

from Transfer import Transfer
from JobStatus import JobStatus

project_path = os.path.abspath(os.path.join('..', 'testproject_transfer'))

class TestTransfer(unittest.TestCase):

    def __init__(self, *args, **kwargs):
        super(TestTransfer, self).__init__(*args, **kwargs)
        self.source_endpoint = 'b9d02196-6d04-11e5-ba46-22000b92c6ec'
        self.destination_endpoint = 'a871c6de-2acd-11e7-bc7c-22000b9a448b'

    def test_transfer_directory(self):
        transfer_directory(
            source_endpoint='b9d02196-6d04-11e5-ba46-22000b92c6ec',
            destination_endpoint='a871c6de-2acd-11e7-bc7c-22000b9a448b',
            src_path='/global/homes/s/sbaldwin/test_directory',
            dst_path=project_path,
            event_list=Event_list(),
            event=threading.Event())

        self.assertTrue(os.path.exists(project_path))
        contents = os.listdir(project_path)
        for item in ['a', 'b', 'c', 'd']:
            self.assertTrue(item in contents)
        shutil.rmtree(project_path)

    def test_transfer_file(self):
        source_file = {
            'remote_path': '/global/homes/s/sbaldwin/test_directory/test_file.txt',
            'local_path': os.path.join(project_path, 'test_file.txt')}
        source_path = '/global/homes/s/sbaldwin/test_directory'
        transfer = Transfer({
            'file_list': [source_file],
            'recursive': False,
            'source_endpoint': self.source_endpoint,
            'destination_endpoint': self.destination_endpoint,
            'source_path': source_path,
            'destination_path': project_path,
            'src_email': '<EMAIL>',
            'display_event': threading.Event(),
            'ui': False
        })
        transfer.execute(event=threading.Event())
        self.assertTrue(transfer.postvalidate())
        self.assertEqual(transfer.status, JobStatus.COMPLETED)


if __name__ == '__main__':
    if os.path.exists(project_path):
        shutil.rmtree(project_path)
    unittest.main()
    if os.path.exists(project_path):
        shutil.rmtree(project_path)<commit_msg>Adds event_list to transfer initiation<commit_after>import unittest
import os
import shutil
import threading
import logging

from lib.util import transfer_directory
from lib.events import Event_list

from Transfer import Transfer
from JobStatus import JobStatus

project_path = os.path.abspath(os.path.join('..', 'testproject_transfer'))

class TestTransfer(unittest.TestCase):

    def __init__(self, *args, **kwargs):
        super(TestTransfer, self).__init__(*args, **kwargs)
        self.source_endpoint = 'b9d02196-6d04-11e5-ba46-22000b92c6ec'
        self.destination_endpoint = 'a871c6de-2acd-11e7-bc7c-22000b9a448b'

    def test_transfer_directory(self):
        transfer_directory(
            source_endpoint='b9d02196-6d04-11e5-ba46-22000b92c6ec',
            destination_endpoint='a871c6de-2acd-11e7-bc7c-22000b9a448b',
            src_path='/global/homes/s/sbaldwin/test_directory',
            dst_path=project_path,
            event_list=Event_list(),
            event=threading.Event())

        self.assertTrue(os.path.exists(project_path))
        contents = os.listdir(project_path)
        for item in ['a', 'b', 'c', 'd']:
            self.assertTrue(item in contents)
        shutil.rmtree(project_path)

    def test_transfer_file(self):
        source_file = {
            'remote_path': '/global/homes/s/sbaldwin/test_directory/test_file.txt',
            'local_path': os.path.join(project_path, 'test_file.txt')}
        source_path = '/global/homes/s/sbaldwin/test_directory'
        transfer = Transfer({
            'file_list': [source_file],
            'recursive': False,
            'source_endpoint': self.source_endpoint,
            'destination_endpoint': self.destination_endpoint,
            'source_path': source_path,
            'destination_path': project_path,
            'src_email': '<EMAIL>',
            'display_event': threading.Event(),
            'ui': False
        }, event_list=Event_list())
        transfer.execute(event=threading.Event())
        self.assertTrue(transfer.postvalidate())
        self.assertEqual(transfer.status, JobStatus.COMPLETED)


if __name__ == '__main__':
    if os.path.exists(project_path):
        shutil.rmtree(project_path)
    unittest.main()
    if os.path.exists(project_path):
        shutil.rmtree(project_path)
{'fraction_non_alphanumeric': 0.11543506777437691, 'fraction_numerical': 0.034980323567993, 'mean_word_length': 2.9507772020725387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7518600', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1452, 'n_words': 222}