<commit_before>from RequestWrapper import RequestWrapper
import unittest

class MockResponseObject(object):

	def __init__(self, text, content):
		self.text = text
		self.content = content

class MockRequestWrapper(RequestWrapper):

	def __init__(self, url, req_type="GET"):
		self.url = url
		self.req_type = req_type.upper()
		self.text = "</html>"
		self.content = b"</html>"

	def make_request(self):
		self.text = "<html>"
		self.content = self.text.encode()

		response = MockResponseObject(self.text, self.content)

		return response

class RequestWrapperUnitTest(unittest.TestCase):

	def test_001(self):
		mock_site = "localsite.com"
		mock_request = MockRequestWrapper(mock_site).make_request()
		# mock_request.make_request()
		self.assertEqual(mock_request.text, "<html>")
		self.assertNotEqual(mock_request.text, "</html>")
		self.assertEqual(mock_request.content, b"<html>")
		self.assertNotEqual(mock_request.content, b"</html>")

if __name__ == "__main__":

	unittest.main()<commit_msg>made modifications to appease pep8 and pylint :P<commit_after>from RequestWrapper import RequestWrapper
import unittest


class MockResponseObject(object):
    '''
    This class creates a mock response object to return when
    called by MockRequestWrapper.
    Requests makes use of request and returns a response object,
    this MockResponseObject is the counter to the MockRequestWrapper.

    Two methods, __init__ and make_response
    '''

    def __init__(self):
        self.text = "<html>"
        self.content = self.text.encode()

    def make_response(self):
        '''
        This method returns self to caller.
        Caller should be MockRequestWrapper
        '''

        return self


class MockRequestWrapper(RequestWrapper):
    '''
    This is object which mocks requests.request

    Three methods, __init__, make_request, get_response
    make_request is the public method that RequestWrapper shares
    and through the use of super in PageRequest we can mock
    that object out.

    get_response is a method which specifically speaks to
    MockResponseObject and leaves implementation of that object
    able to change in the future.
    '''

    def __init__(self, url, req_type="GET"):

        self.url = url
        self.req_type = req_type.upper()

    def make_request(self):
        '''
        This method mocks a request from Requests library.
        It inherits from both RequestWrapper and MockResponseObject.
        Should call MockResponseObject and pass back mock response.
        '''

        return self.get_response()

    def get_response(self):
        '''
        This method carries the dependency to MockResponseObject
        Passes back response
        '''

        mock_response_object = MockResponseObject()
        response = mock_response_object.make_response()
        return response


class RequestWrapperUnitTest(unittest.TestCase):

    def test_001(self):
        '''
        Sets up and executes test on MockRequestWrapper and MockResponseObject
        which are tested in this file only.
        These are really a library that allow PageRequest.py
        to run integration tests.
        '''
        # Test setup and initialization
        mock_site = "localsite.com"
        mock_request = MockRequestWrapper(mock_site)
        mock_response = mock_request.make_request()

        # Tests
        self.assertEqual(mock_response.text, "<html>")
        self.assertNotEqual(mock_response.text, "</html>")
        self.assertEqual(mock_response.content, b"<html>")
        self.assertNotEqual(mock_response.content, b"</html>")


if __name__ == "__main__":

    unittest.main()
{'fraction_non_alphanumeric': 0.0856830002737476, 'fraction_numerical': 0.0019162332329592116, 'mean_word_length': 3.2340672074159906, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, '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': '2931902', 'n_tokens_mistral': 1023, 'n_tokens_neox': 982, 'n_words': 296}