# Path: native_tags/registry.py
# def register(self, bucket, name_or_func, func=None):
#     """
#     Add a function to the registry by name
#     """
#     assert bucket in self, 'Bucket %s is unknown' % bucket
#     if func is None and hasattr(name_or_func, '__name__'):
#         name = name_or_func.__name__
#         func = name_or_func
#     elif func:
#         name = name_or_func
#     if name in self[bucket]:
#         raise AlreadyRegistered('The function %s is already registered' % name)
# 
#     self[bucket][name] = func
# 
# class AlreadyRegistered(Exception):
#     "The function you are trying to register is already in the registry"
#     pass
# 
# Path: native_tags/nodes.py
# def get_cache_key(bucket, name, args, kwargs):
#     """
#     Gets a unique SHA1 cache key for any call to a native tag.
#     Use args and kwargs in hash so that the same arguments use the same key
#     """
#     u = ''.join(map(str, (bucket, name, args, kwargs)))
#     return 'native_tags.%s' % sha_constructor(u).hexdigest()


import datetime
        import math
        import hashlib
        import pygments
        import GChartWrapper
        import feedparser
        import markdown
from django.contrib.auth.models import User
from django.template import Template, Context, TemplateSyntaxError
from django.test import TestCase
from django.core.serializers import deserialize
from django.core.cache import cache
from native_tags.registry import register, AlreadyRegistered
from native_tags.nodes import get_cache_key
        from native_tags.nodes import split
        t = "{% for i in items %}{% add 1 i as roomba %}{{roomba}}{% endfor %}"
        o = render(t, {'items':[1,2,3]})
        self.assertEqual(o, "234")
    
    def test_b64encode(self):
        self.assertEqual(render('{% b64encode "hello world" %}'), 'aGVsbG8gd29ybGQ=')
    
    def test_b64decode(self):
        self.assertEqual(render('{% b64decode encoded %}', {'encoded':'aGVsbG8gd29ybGQ='}), 'hello world')
    
    def test_dynamic(self):
        self.assertEqual(eval(render('{% dynamic a b c d=1 e=2 %}')),
                          ['a', 'b', 'c', ('d', 1), ('e', 2)])
    
    def test_no_render(self):
        self.assertEqual(eval(render('{% no_render a b c d d=1 e=2 f=var %}', {'var':'hello'})),
                          ['a', 'b', 'c', 'd', ('d', '1'), ('e', '2'), ('f', 'var')])
    
    def test_filter_args(self):
        self.assertEqual(render('{{ var|myfilter:"baz" }}', {'var':'foobar'}), 'foobarbaz')
    
    def test_adder(self):
        self.assertEqual(render('{% load native humanize %}{% add 1000 100 as num %}{{ num|intcomma }}'), '1,100')
    
    def test_cmp_kwargs(self):
        self.assertEqual(render('{% if_cmp_kwargs foo=bar %}yup{% endif_cmp_kwargs %}'), 'yup')
    
    def test_zremove_tag(self):
        self.assert_('add' in register['function'])
        register.unregister('function', 'add')

# Path: native_tags/registry.py
# def register(self, bucket, name_or_func, func=None):
#     """
#     Add a function to the registry by name
#     """
#     assert bucket in self, 'Bucket %s is unknown' % bucket
#     if func is None and hasattr(name_or_func, '__name__'):
#         name = name_or_func.__name__
#         func = name_or_func
#     elif func:
#         name = name_or_func
#     if name in self[bucket]:
#         raise AlreadyRegistered('The function %s is already registered' % name)
# 
#     self[bucket][name] = func
# 
# class AlreadyRegistered(Exception):
#     "The function you are trying to register is already in the registry"
#     pass
# 
# Path: native_tags/nodes.py
# def get_cache_key(bucket, name, args, kwargs):
#     """
#     Gets a unique SHA1 cache key for any call to a native tag.
#     Use args and kwargs in hash so that the same arguments use the same key
#     """
#     u = ''.join(map(str, (bucket, name, args, kwargs)))
#     return 'native_tags.%s' % sha_constructor(u).hexdigest()


# Path: example_project/app/tests.py
import datetime
        import math
        import hashlib
        import pygments
        import GChartWrapper
        import feedparser
        import markdown
from django.contrib.auth.models import User
from django.template import Template, Context, TemplateSyntaxError
from django.test import TestCase
from django.core.serializers import deserialize
from django.core.cache import cache
from native_tags.registry import register, AlreadyRegistered
from native_tags.nodes import get_cache_key
        from native_tags.nodes import split

        t = "{% for i in items %}{% add 1 i as roomba %}{{roomba}}{% endfor %}"
        o = render(t, {'items':[1,2,3]})
        self.assertEqual(o, "234")
    
    def test_b64encode(self):
        self.assertEqual(render('{% b64encode "hello world" %}'), 'aGVsbG8gd29ybGQ=')
    
    def test_b64decode(self):
        self.assertEqual(render('{% b64decode encoded %}', {'encoded':'aGVsbG8gd29ybGQ='}), 'hello world')
    
    def test_dynamic(self):
        self.assertEqual(eval(render('{% dynamic a b c d=1 e=2 %}')),
                          ['a', 'b', 'c', ('d', 1), ('e', 2)])
    
    def test_no_render(self):
        self.assertEqual(eval(render('{% no_render a b c d d=1 e=2 f=var %}', {'var':'hello'})),
                          ['a', 'b', 'c', 'd', ('d', '1'), ('e', '2'), ('f', 'var')])
    
    def test_filter_args(self):
        self.assertEqual(render('{{ var|myfilter:"baz" }}', {'var':'foobar'}), 'foobarbaz')
    
    def test_adder(self):
        self.assertEqual(render('{% load native humanize %}{% add 1000 100 as num %}{{ num|intcomma }}'), '1,100')
    
    def test_cmp_kwargs(self):
        self.assertEqual(render('{% if_cmp_kwargs foo=bar %}yup{% endif_cmp_kwargs %}'), 'yup')
    
    def test_zremove_tag(self):
        self.assert_('add' in register['function'])
        register.unregister('function', 'add')

        self.assert_(not 'add' in register['function'])