<commit_before>from view import GrokRestViewMixin
from fancyhtmlview import GrokRestViewWithFancyHtmlMixin


class MockResponse(object):
    def __init__(self):
        self.headers = []
        self.status = None

    def setHeader(self, header, value):
        self.headers.append((header, value))

    def setStatus(self, code, msg):
        self.status = (code, msg)


class MockRequest(object):
    def __init__(self, method='GET', body='', getdata={},
                 headers={'Accept': 'application/json'}):
        self.method = method
        self.body = body
        self.getdata = {'BODY': self.body}
        self.getdata.update(getdata)
        self.headers = {}
        for header, value in headers.iteritems():
            self.headers[header.lower()] = value

    def get(self, key, default=None):
        return self.getdata.get(key, default)

    def getHeader(self, header):
        return self.headers[header.lower()]


class MockContext(object):
    def __init__(self, parentnode=None, id=None):
        self.parentnode = parentnode
        self.id = id

    def getParentNode(self):
        return self.parentnode


class MockRestView(GrokRestViewMixin):
    def __init__(self, request=None, response=MockResponse(), context=None):
        self.request = request
        self.response = response
        self.context = context

class MockRestViewWithFancyHtml(GrokRestViewWithFancyHtmlMixin):
    def __init__(self, request=None, response=MockResponse(), context=None):
        self.request = request
        self.response = response
        self.context = context
<commit_msg>Updated the mock Request to store body in stdin.<commit_after>from view import GrokRestViewMixin
from fancyhtmlview import GrokRestViewWithFancyHtmlMixin
from StringIO import StringIO


class MockResponse(object):
    def __init__(self):
        self.headers = []
        self.status = None

    def setHeader(self, header, value):
        self.headers.append((header, value))

    def setStatus(self, code, msg):
        self.status = (code, msg)


class MockRequest(object):
    def __init__(self, method='GET', body='', getdata={},
                 headers={'Accept': 'application/json'}):
        self.method = method
        self.body = body
        self.getdata = {} #'BODY': self.body}
        self.getdata.update(getdata)
        self.headers = {}
        self.stdin = StringIO(body)
        for header, value in headers.iteritems():
            self.headers[header.lower()] = value

    def get(self, key, default=None):
        return self.getdata.get(key, default)

    def getHeader(self, header):
        return self.headers[header.lower()]


class MockContext(object):
    def __init__(self, parentnode=None, id=None):
        self.parentnode = parentnode
        self.id = id

    def getParentNode(self):
        return self.parentnode


class MockRestView(GrokRestViewMixin):
    def __init__(self, request=None, response=MockResponse(), context=None):
        self.request = request
        self.response = response
        self.context = context

class MockRestViewWithFancyHtml(GrokRestViewWithFancyHtmlMixin):
    def __init__(self, request=None, response=MockResponse(), context=None):
        self.request = request
        self.response = response
        self.context = context

{'fraction_non_alphanumeric': 0.10872198667474257, 'fraction_numerical': 0.0, 'mean_word_length': 2.965186074429772, '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': '4469726', 'n_tokens_mistral': 945, 'n_tokens_neox': 930, 'n_words': 224}