<commit_before>from __future__ import (
    generators,
    division,
    absolute_import,
    with_statement,
    print_function,
    unicode_literals,
    nested_scopes
)
import sys
import copy
import json
import os.path
import unittest
from hashlib import sha256
from io import BytesIO

if sys.version_info.major == 3:
    from unittest.mock import patch, Mock
else:
    from mock import patch, Mock

from metacore import storj
from metacore.database import files
from metacore.error_codes import *
from metacore.tests import *

__author__ = 'karatel'


class UploadFileCase(unittest.TestCase):
    """
    Test uploading files to the Node.
    """

    url = '/api/files/'

    def setUp(self):
        """
        Switch to test config.
        Remember initial records in the 'files' table.
        Remember initial files set in the Upload Dir.
        Remember initial blacklist content.
        """
        self.app = storj.app
        self.app.config['TESTING'] = True
        self.files = set(tuple(_) for _ in files.select().execute())
        self.stored_files = set(os.listdir(self.app.config['UPLOAD_FOLDER']))

        self.file_data = b'some data'
        valid_hash = sha256(self.file_data).hexdigest()<commit_msg>done: clean-up in all tests; refactor: test_upload.py<commit_after>import sys
import copy
import json
import os.path
import unittest
from hashlib import sha256
from io import BytesIO

from metacore import storj
from metacore.database import files
from metacore.error_codes import *
from metacore.tests import *

if sys.version_info.major == 3:
    from unittest.mock import patch, Mock
else:
    from mock import patch, Mock


__author__ = 'karatel'


class UploadFileCase(unittest.TestCase):
    """
    Test uploading files to the Node.
    """

    url = '/api/files/'

    def setUp(self):
        """
        Switch to test config.
        Remember initial records in the 'files' table.
        Remember initial files set in the Upload Dir.
        Remember initial blacklist content.
        """
        self.app = storj.app
        self.app.config['TESTING'] = True
        self.files = set(tuple(_) for _ in files.select().execute())
        self.stored_files = set(os.listdir(self.app.config['UPLOAD_FOLDER']))

        self.file_data = b'some data'
        valid_hash = sha256(self.file_data).hexdigest()
{'fraction_non_alphanumeric': 0.08997867803837953, 'fraction_numerical': 0.005970149253731343, 'mean_word_length': 2.8970099667774085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7531568', 'n_tokens_mistral': 720, 'n_tokens_neox': 701, 'n_words': 213}