<commit_before>#!/usr/bin/python3.6
import json
import unittest

from lib import webutil as webutil


class RankTests(unittest.TestCase):

    def testRespondSuccess(self):

        # Arrange
        message = 'message'
        expected_result = {
            'statusCode': 200,
            'headers': {
                'Content-Type': 'text/plain',
            },
            'body': message
        }

        # Act
        result = webutil.respond_success(message)

        # Assert
        self.assertDictEqual(expected_result, result)

    def testRespondSuccessJson(self):

        # Arrange
        body = {
            'array': [0, 1, 2],
            'string': 'something'
        }
        expected_result = {
            'statusCode': 200,
            'headers': {
                'Content-Type': 'application/json',
            },
            'body': json.dumps(body)
        }

        # Act
        result = webutil.respond_success_json(json.dumps(body))

        # Assert
        self.assertDictEqual(expected_result, result)

    def testRespondServerError(self):

        # Arrange
        message = 'message'
        expected_result = {
            'statusCode': 500,
            'headers': {
                'Content-Type': 'text/plain',
            },
            'body': message
        }

        # Act
        result = webutil.respond_server_error(message)

        # Assert
        self.assertDictEqual(expected_result, result)

    def testRespondUnauthorized(self):

        # Arrange
        message = 'message'
        expected_result = {
            'statusCode': 401,
            'headers': {
                'Content-Type': 'text/plain',
            },
            'body': message
        }

        # Act
        result = webutil.respond_unauthorized(message)

        # Assert
        self.assertDictEqual(expected_result, result)<commit_msg>fix webutil unit tests<commit_after>#!/usr/bin/python3.6
import json
import unittest

from lib import webutil as webutil


class RankTests(unittest.TestCase):

    def testRespondSuccess(self):

        # Arrange
        message = 'message'
        expected_result = {
            'statusCode': 200,
            'headers': {
                'Content-Type': 'text/plain',
            },
            'body': message
        }

        # Act
        result = webutil.respond_success(message)

        # Assert
        self.assertDictEqual(expected_result, result)

    def testRespondSuccessJson(self):

        # Arrange
        body = {
            'array': [0, 1, 2],
            'string': 'something'
        }
        expected_result = {
            'statusCode': 200,
            'headers': {
                'Content-Type': 'application/json',
                'Access-Control-Allow-Origin': '*'
            },
            'body': json.dumps(body)
        }

        # Act
        result = webutil.respond_success_json(json.dumps(body))

        # Assert
        self.assertDictEqual(expected_result, result)

    def testRespondServerError(self):

        # Arrange
        message = 'message'
        expected_result = {
            'statusCode': 500,
            'headers': {
                'Content-Type': 'text/plain',
                'Access-Control-Allow-Origin': '*'
            },
            'body': message
        }

        # Act
        result = webutil.respond_server_error(message)

        # Assert
        self.assertDictEqual(expected_result, result)

    def testRespondUnauthorized(self):

        # Arrange
        message = 'message'
        expected_result = {
            'statusCode': 401,
            'headers': {
                'Content-Type': 'text/plain',
                'Access-Control-Allow-Origin': '*'
            },
            'body': message
        }

        # Act
        result = webutil.respond_unauthorized(message)

        # Assert
        self.assertDictEqual(expected_result, result)
{'fraction_non_alphanumeric': 0.1071611253196931, 'fraction_numerical': 0.008695652173913044, 'mean_word_length': 1.537962362102531, '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': '7286805', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1045, 'n_words': 193}