<commit_before>from twisted.trial import unittest
import json

from .. import server
from ._dummyresource import DummyRootResource, DummySite


class FileServerResourceTests(unittest.TestCase):

    def setUp(self):
        self.hosting = []
        self._resourceToTest = server.FileServerResource(self.hosting)
        self._resource = DummyRootResource('files', self._resourceToTest)
        self.web = DummySite(self._resource)

    def test_posting_file_and_path_returns_new_location(self):
        d = self.web.post('files', {'serveat': 'foo', 'filepath': '/bar'}, headers=server.HEADERS)
        def check(response):
            resp = json.loads(response.value())
            self.assertTrue(resp['url'] == 'localhost/foo')
        d.addCallback(check)
        return d<commit_msg>add test to make sure files are added on post<commit_after>from twisted.trial import unittest
import json

from .. import server
from ._dummyresource import DummyRootResource, DummySite


class FileServerResourceTests(unittest.TestCase):

    def setUp(self):
        self.hosting = []
        self._resourceToTest = server.FileServerResource(self.hosting)
        self._resource = DummyRootResource('files', self._resourceToTest)
        self.web = DummySite(self._resource)

    def test_posting_file_and_path_returns_new_location(self):
        d = self.web.post('files', {'serveat': 'foo', 'filepath': '/bar'}, headers=server.HEADERS)
        def check(response):
            resp = json.loads(response.value())
            self.assertTrue(resp['url'] == 'localhost/foo')
        d.addCallback(check)
        return d

    def test_posting_file_adds_filename_and_path_to_hosts(self):
        d = self.web.post('files', {'serveat': 'foo', 'filepath': '/bar'}, headers=server.HEADERS)
        def check(ignored):
            self.assertTrue(self.hosting[0] == ('foo', '/bar'))
        d.addCallback(check)
        return d
{'fraction_non_alphanumeric': 0.12127548353371667, 'fraction_numerical': 0.0005227391531625719, 'mean_word_length': 3.389908256880734, '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': '6059876', 'n_tokens_mistral': 565, 'n_tokens_neox': 559, 'n_words': 113}