<commit_before>"""Tests for http parsing."""
import unittest2

from hanzo.httptools.messaging import RequestMessage, ResponseMessage

get_request_lines = [
        "GET / HTTP/1.1",
        "Host: example.org",
        "",
        "",
        ]
get_request = "\r\n".join(get_request_lines)
get_response_lines = [
        "HTTP/1.1 200 OK",
        "Host: example.org",
        "Content-Length: 5",
        "",
        "tests",
        ]
get_response = "\r\n".join(get_response_lines)

class GetChar(unittest2.TestCase):
    """Test basic GET request parsing. Single character at a time."""
    def runTest(self):
        """Attempts to parse the contents of get_request and
        get_response."""
        p = RequestMessage()
        for t in get_request:
            text = p.feed(t)
            self.assertEqual(text, '')

        self.assertTrue(p.headers_complete())
        self.assertTrue(p.complete())

        self.assertEqual(get_request, p.get_decoded_message())

        p = ResponseMessage(p)
        for char in get_response:
            text = p.feed(char)
            self.assertEqual(text, '')

        self.assertTrue(p.headers_complete())
        self.assertTrue(p.complete())
        self.assertEqual(get_response, p.get_decoded_message())
        self.assertEqual("test", p.get_body())
<commit_msg>Should be "tests" not "test"<commit_after>"""Tests for http parsing."""
import unittest2

from hanzo.httptools.messaging import RequestMessage, ResponseMessage

get_request_lines = [
        "GET / HTTP/1.1",
        "Host: example.org",
        "",
        "",
        ]
get_request = "\r\n".join(get_request_lines)
get_response_lines = [
        "HTTP/1.1 200 OK",
        "Host: example.org",
        "Content-Length: 5",
        "",
        "tests",
        ]
get_response = "\r\n".join(get_response_lines)

class GetChar(unittest2.TestCase):
    """Test basic GET request parsing. Single character at a time."""
    def runTest(self):
        """Attempts to parse the contents of get_request and
        get_response."""
        p = RequestMessage()
        for t in get_request:
            text = p.feed(t)
            self.assertEqual(text, '')

        self.assertTrue(p.headers_complete())
        self.assertTrue(p.complete())

        self.assertEqual(get_request, p.get_decoded_message())

        p = ResponseMessage(p)
        for char in get_response:
            text = p.feed(char)
            self.assertEqual(text, '')

        self.assertTrue(p.headers_complete())
        self.assertTrue(p.complete())
        self.assertEqual(get_response, p.get_decoded_message())
        self.assertEqual("tests", p.get_body())

{'fraction_non_alphanumeric': 0.12951807228915663, 'fraction_numerical': 0.007530120481927711, 'mean_word_length': 2.367553865652725, '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': '5755724', 'n_tokens_mistral': 799, 'n_tokens_neox': 788, 'n_words': 164}