# Path: nappingcat/patterns.py
# def patterns(path, *args):
#     return CommandPatterns(path, args) 
# 
# Path: nappingcat/exceptions.py
# class NappingCatUnhandled(NappingCatException):
#     pass
# 
# class NappingCatBadPatterns(NappingCatBadConfig):
#     pass


from unittest import TestCase
from nappingcat import patterns
from nappingcat.exceptions import NappingCatUnhandled, NappingCatBadPatterns
import random
        test_fn = lambda *args, **kwargs: random_result
        pat = patterns.CommandPatterns('', [('^hey', TriggerCommandPatterns('', [])), ('^hey', test_fn)])
        target, match = pat.match('hey')
        self.assertEqual(target, test_fn)
        self.assertTrue(hasattr(match, 'groupdict'))    # not a great way to test whether or not it's a regex match object...

    def test_attempts_to_grab_str_target_off_of_module(self):
        pat = patterns.CommandPatterns('tests.patterns', [
            ('^hey', 'test_fn'),
            ('^yo', 'dne'),
        ])
        target, match = pat.match('hey')
        self.assertEqual(target, test_fn)
        self.assertTrue(hasattr(match, 'groupdict'))    # not a great way to test whether or not it's a regex match object...
        self.assertRaises(AttributeError, pat.match, 'yo')

    def test_raises_nappingcat_exception_if_target_is_not_a_string_patterns_or_callable(self):
        pat = patterns.CommandPatterns('tests.patterns', [
            ('^hey', random.randint(1,100)),
        ])
        self.assertRaises(NappingCatBadPatterns, pat.match, 'hey')

    def test_add_returns_new_patterns(self):
        hey_value, yo_value = random.randint(1,100), random.randint(1,100)
        pat = patterns.CommandPatterns('tests.patterns', [
            ('^hey', lambda x: hey_value),
        ])
        rhs = patterns.CommandPatterns('tests.patterns', [
            ('^yo', lambda x: yo_value),
        ])

# Path: nappingcat/patterns.py
# def patterns(path, *args):
#     return CommandPatterns(path, args) 
# 
# Path: nappingcat/exceptions.py
# class NappingCatUnhandled(NappingCatException):
#     pass
# 
# class NappingCatBadPatterns(NappingCatBadConfig):
#     pass


# Path: tests/patterns.py
from unittest import TestCase
from nappingcat import patterns
from nappingcat.exceptions import NappingCatUnhandled, NappingCatBadPatterns
import random

        test_fn = lambda *args, **kwargs: random_result
        pat = patterns.CommandPatterns('', [('^hey', TriggerCommandPatterns('', [])), ('^hey', test_fn)])
        target, match = pat.match('hey')
        self.assertEqual(target, test_fn)
        self.assertTrue(hasattr(match, 'groupdict'))    # not a great way to test whether or not it's a regex match object...

    def test_attempts_to_grab_str_target_off_of_module(self):
        pat = patterns.CommandPatterns('tests.patterns', [
            ('^hey', 'test_fn'),
            ('^yo', 'dne'),
        ])
        target, match = pat.match('hey')
        self.assertEqual(target, test_fn)
        self.assertTrue(hasattr(match, 'groupdict'))    # not a great way to test whether or not it's a regex match object...
        self.assertRaises(AttributeError, pat.match, 'yo')

    def test_raises_nappingcat_exception_if_target_is_not_a_string_patterns_or_callable(self):
        pat = patterns.CommandPatterns('tests.patterns', [
            ('^hey', random.randint(1,100)),
        ])
        self.assertRaises(NappingCatBadPatterns, pat.match, 'hey')

    def test_add_returns_new_patterns(self):
        hey_value, yo_value = random.randint(1,100), random.randint(1,100)
        pat = patterns.CommandPatterns('tests.patterns', [
            ('^hey', lambda x: hey_value),
        ])
        rhs = patterns.CommandPatterns('tests.patterns', [
            ('^yo', lambda x: yo_value),
        ])

        newpat = pat + rhs