<commit_before>import unittest

from RequestWrapper import RequestWrapper
from MockRequestWrapper import MockRequestWrapper


class PageRequest(RequestWrapper):
    '''
    This class initializes with a url and has only a single method - crawl
    Crawl calls super() to make_request().
    Since PageRequest inherits from RequestWrapper, PageRequest will
    make a call to RequestWrapper.make_request() under normal circumstances.

    However MockPageRequest inherits from MockRequestWrapper as well
    and super() allows to inject the mocking dependencies which allow
    for integration testing of the entire application.
    '''
    def __init__(self, url):
        ''' May want to clean up use of super into init '''
        self.url = url

    def crawl(self):
        '''
        Calls super() to initialize either RequestWrapper/MockRequestWrapper
        Creates a variable called response, which needs to know that
        request method make_request, and contains the logic of the crawler
        Returns the entire response object
        '''
        super().__init__(self.url)
        # print ("Hitting %s url" % (self.url))
        response = super().make_request()
        # print (response.text[0:50])

        return response


class MockPageRequest(PageRequest, MockRequestWrapper):
    pass


class PageRequestUnitTest(unittest.TestCase):
    ''' Class contains two unit tests for PageRequest '''

    def test_001(self):
        ''' Test 1 looks at a real url and confirms text isn't blank '''<commit_msg>Moving super().__init__ into the __init__ method<commit_after>import unittest

from RequestWrapper import RequestWrapper
from MockRequestWrapper import MockRequestWrapper


class PageRequest(RequestWrapper):
    '''
    This class initializes with a url and has only a single method - crawl
    Crawl calls super() to make_request().
    Since PageRequest inherits from RequestWrapper, PageRequest will
    make a call to RequestWrapper.make_request() under normal circumstances.

    However MockPageRequest inherits from MockRequestWrapper as well
    and super() allows to inject the mocking dependencies which allow
    for integration testing of the entire application.
    '''
    def __init__(self, url):
        ''' May want to clean up use of super into init '''
        super().__init__(url)

    def crawl(self):
        '''
        Calls super() to initialize either RequestWrapper/MockRequestWrapper
        Creates a variable called response, which needs to know that
        request method make_request, and contains the logic of the crawler
        Returns the entire response object
        '''
        # print ("Hitting %s url" % (self.url))
        response = super().make_request()
        # print (response.text[0:50])

        return response


class MockPageRequest(PageRequest, MockRequestWrapper):
    pass


class PageRequestUnitTest(unittest.TestCase):
    ''' Class contains two unit tests for PageRequest '''

    def test_001(self):
        ''' Test 1 looks at a real url and confirms text isn't blank '''
{'fraction_non_alphanumeric': 0.06856023506366307, 'fraction_numerical': 0.004570682337577538, 'mean_word_length': 3.2555555555555555, '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': '3984455', 'n_tokens_mistral': 754, 'n_tokens_neox': 720, 'n_words': 315}