<commit_before>import unittest
import ec2_lex_bot

class TestReadFunctions(unittest.TestCase):

    def setUp(self):
        self.mock_event = {
          "currentIntent": {
            "name": "intent-name",
            "slots": {
              "slot-name": "value",
              "slot-name": "value",
              "slot-name": "value"
            },
            "confirmationStatus": "None, Confirmed, or Denied (intent confirmation, if configured)",
          },
          "bot": {
            "name": "bot-name",
            "alias": "bot-alias",
            "version": "bot-version"
          },
          "userId": "user-id specified in the POST request to Amazon Lex.",
          "inputTranscript": "Text used to process the request",
          "invocationSource": "FulfillmentCodeHook or DialogCodeHook",
          "outputDialogMode": "Text or Voice, based on ContentType request header in runtime API request",
          "messageVersion": "1.0",
          "sessionAttributes": { 
             "key1": "value1",
             "key2": "value2"
          }
        }

    def test_num_instances(self):
        self.mock_event["currentIntent"]["name"] = "RunningInstances"
        output = ec2_lex_bot.lambda_handler(self.mock_event,'null')
        self.assertEqual(len(output["dialogAction"]["message"]["content"].split()), 5)

if __name__ == '__main__':
    unittest.main()<commit_msg>Add instance status test<commit_after>import unittest
import ec2_lex_bot
import re

class TestReadFunctions(unittest.TestCase):

    def setUp(self):
        self.mock_event = {
          "currentIntent": {
            "name": "intent-name",
            "slots": {
              "slot-name": "value",
              "slot-name": "value",
              "slot-name": "value"
            },
            "confirmationStatus": "None, Confirmed, or Denied (intent confirmation, if configured)",
          },
          "bot": {
            "name": "bot-name",
            "alias": "bot-alias",
            "version": "bot-version"
          },
          "userId": "user-id specified in the POST request to Amazon Lex.",
          "inputTranscript": "Text used to process the request",
          "invocationSource": "FulfillmentCodeHook or DialogCodeHook",
          "outputDialogMode": "Text or Voice, based on ContentType request header in runtime API request",
          "messageVersion": "1.0",
          "sessionAttributes": { 
             "key1": "value1",
             "key2": "value2"
          }
        }

    def test_num_instances(self):
        self.mock_event["currentIntent"]["name"] = "RunningInstances"
        output = ec2_lex_bot.lambda_handler(self.mock_event, None)
        regex = re.compile('There are [1-9]\d* instances running\.')
        match = regex.match(output["dialogAction"]["message"]["content"])
        self.assertIsNotNone(match)

    def test_instance_status(self):
        self.mock_event["currentIntent"]["name"] = "InstanceStatus"
        output = ec2_lex_bot.lambda_handler(self.mock_event, None)
        regex = re.compile('i-[a-f0-9]{8}, a (Windows|Linux) instance, is currently (pending|running|shutting down|terminated|stopping|stopped)\.')
        match = regex.match(output["dialogAction"]["message"]["content"])
        self.assertIsNotNone(match)
        
if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.13788968824940048, 'fraction_numerical': 0.006894484412470024, 'mean_word_length': 2.337, 'pattern_counts': {'":': 38, '<': 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': '270856', 'n_tokens_mistral': 945, 'n_tokens_neox': 951, 'n_words': 207}