<commit_before><commit_msg>Add test of the AlreadyExistsException and the NotFoundException, when creating or deleting databases<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Unit tests for pyes.  These require an es server with thrift plugin running on the default port (localhost:9500).
"""
import unittest
from pyes.tests import ESTestCase
import pyes.exceptions

class ErrorReportingTestCase(ESTestCase):
    def setUp(self):
        super(ErrorReportingTestCase, self).setUp()

    def testCreateDelete(self):
        """

        Test errors thrown when creating or deleting.

        """
        try:
            self.conn.delete_index("test-index")
        except pyes.exceptions.NotFoundException:
            pass
        self.conn.create_index("test-index")
        self.assertRaises(pyes.exceptions.AlreadyExistsException, self.conn.create_index, "test-index")
        self.conn.delete_index("test-index")
        self.assertRaises(pyes.exceptions.NotFoundException, self.conn.delete_index, "test-index")

if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.10492107706592387, 'fraction_numerical': 0.004642525533890436, 'mean_word_length': 3.4730290456431536, 'pattern_counts': {'":': 1, '<': 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': '471030', 'n_tokens_mistral': 313, 'n_tokens_neox': 301, 'n_words': 73}