<commit_before>import logging
import sys
from easy_alert.entity.level import Level

if sys.version_info < (2, 7):
    import unittest2 as unittest
else:
    import unittest


class TestLevel(unittest.TestCase):
    def test_init_error(self):
        def assert_err(arg, expect):
            with self.assertRaises(KeyError) as cm:
                Level(arg)
            self.assertEqual(cm.exception.args[0], expect)

        assert_err(1.23, 'Invalid level: 1.23')
        assert_err('', 'Unknown level string: ')
        assert_err('Info', 'Unknown level string: Info')
        assert_err('INFO', 'Unknown level string: INFO')

    def test_get_keyword(self):
        self.assertEqual(Level(logging.DEBUG).get_keyword(), 'debug')
        self.assertEqual(Level(logging.INFO).get_keyword(), 'info')
        self.assertEqual(Level(logging.WARN).get_keyword(), 'warn')
        self.assertEqual(Level(logging.ERROR).get_keyword(), 'error')
        self.assertEqual(Level(logging.CRITICAL).get_keyword(), 'critical')<commit_msg>add tests for Level<commit_after>import logging
import sys
from easy_alert.entity.level import Level

if sys.version_info < (2, 7):
    import unittest2 as unittest
else:
    import unittest


class TestLevel(unittest.TestCase):
    def test_init_error(self):
        def assert_err(arg, expect):
            with self.assertRaises(KeyError) as cm:
                Level(arg)
            self.assertEqual(cm.exception.args[0], expect)

        assert_err(1.23, 'Invalid level: 1.23')
        assert_err('', 'Unknown level string: ')
        assert_err('Info', 'Unknown level string: Info')
        assert_err('INFO', 'Unknown level string: INFO')

    def test_get_keyword(self):
        self.assertEqual(Level(logging.DEBUG).get_keyword(), 'debug')
        self.assertEqual(Level(logging.INFO).get_keyword(), 'info')
        self.assertEqual(Level(logging.WARN).get_keyword(), 'warn')
        self.assertEqual(Level(logging.ERROR).get_keyword(), 'error')
        self.assertEqual(Level(logging.CRITICAL).get_keyword(), 'critical')

    def test_cmp(self):
        self.assertTrue(Level('warn') < Level('error'))
        self.assertTrue(Level('debug') <= Level('debug'))
        self.assertTrue(Level('info') == Level(20))
        self.assertTrue(Level('critical') >= Level('debug'))
        self.assertTrue(Level('critical') > Level('debug'))

    def test_repr(self):
        self.assertEqual(repr(Level('critical')), 'Level(level=50)')
        self.assertEqual(repr(Level('error')), 'Level(level=40)')
        self.assertEqual(repr(Level('warn')), 'Level(level=30)')
        self.assertEqual(repr(Level('info')), 'Level(level=20)')
        self.assertEqual(repr(Level('debug')), 'Level(level=10)')
{'fraction_non_alphanumeric': 0.1489908256880734, 'fraction_numerical': 0.011743119266055046, 'mean_word_length': 3.596964586846543, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '3731710', 'n_tokens_mistral': 825, 'n_tokens_neox': 798, 'n_words': 152}