<commit_before>import json

from echo.response import EchoResponse, EchoSimplePlainTextResponse
from echo.tests import BaseEchoTestCase


class TestEchoSimplePlainTextResponse(BaseEchoTestCase):
    def test_populates_text_in_response(self):
        """The Plain text response should populate the outputSpeech"""
        expected = "This is the text"
        response = EchoSimplePlainTextResponse(expected)
        data = json.loads(response.content)

        assert data['response']['outputSpeech']['type'] == EchoResponse.PLAIN_TEXT_OUTPUT
        assert data['response']['outputSpeech']['text'] == expected

    def test_populates_session(self):
        """The Plain text response should populate the session attributes"""
        expected = {'apple': 'red', 'orange': 'orange'}
        response = EchoSimplePlainTextResponse('text', session=expected)
        data = json.loads(response.content)

        assert data['sessionAttributes'] == expected

    def test_sets_end_session_bool(self):
        """The Plain text response should be able to set the end_session bool"""
        response = EchoSimplePlainTextResponse('text', end_session=False)
        data = json.loads(response.content)
        assert not data['response']['shouldEndSession']<commit_msg>Fix response tests in py3<commit_after>import json

from echo.response import EchoResponse, EchoSimplePlainTextResponse
from echo.tests import BaseEchoTestCase


class TestEchoSimplePlainTextResponse(BaseEchoTestCase):
    def test_populates_text_in_response(self):
        """The Plain text response should populate the outputSpeech"""
        expected = "This is the text"
        response = EchoSimplePlainTextResponse(expected)
        data = json.loads(response.content.decode())

        assert data['response']['outputSpeech']['type'] == EchoResponse.PLAIN_TEXT_OUTPUT
        assert data['response']['outputSpeech']['text'] == expected

    def test_populates_session(self):
        """The Plain text response should populate the session attributes"""
        expected = {'apple': 'red', 'orange': 'orange'}
        response = EchoSimplePlainTextResponse('text', session=expected)
        data = json.loads(response.content.decode())

        assert data['sessionAttributes'] == expected

    def test_sets_end_session_bool(self):
        """The Plain text response should be able to set the end_session bool"""
        response = EchoSimplePlainTextResponse('text', end_session=False)
        data = json.loads(response.content.decode())
        assert not data['response']['shouldEndSession']
{'fraction_non_alphanumeric': 0.10331384015594541, 'fraction_numerical': 0.0003898635477582846, 'mean_word_length': 4.215447154471545, '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': '5295254', 'n_tokens_mistral': 672, 'n_tokens_neox': 641, 'n_words': 171}