<commit_before>from django.test import TestCase
from django import template

from google_analytics.templatetags import analytics 

class ParserTest(TestCase):
    def setUp(self):
        self.parser = "unused"
        #################################
        # Pathological case - Do not test
        #self.token_null = template.Token(template.TOKEN_BLOCK, "")
        #################################

        self.token_noarg = template.Token(template.TOKEN_BLOCK, "test")
        self.token_onearg = template.Token(template.TOKEN_BLOCK, "test 'UA-888888-1'")
        self.token_twoarg = template.Token(template.TOKEN_BLOCK, "test 'UA-888888-1' 'UA-999999-2'")

    def test_setup(self):
        self.assert_(True)

    def test_basic_return(self):
        node = analytics.do_get_analytics(self.parser, self.token_noarg)
        self.assertTrue(isinstance(node, template.Node))

    def _test_null_node_template(self):
        node = analytics.do_get_analytics(self.parser, self.token_null)
        self.assertEqual(node.template_name, 'google_analytics/_template.html')

    def test_noarg_node_template(self):
        node = analytics.do_get_analytics(self.parser, self.token_noarg)
        self.assertEqual(node.template_name, 'google_analytics/test_template.html')
    
    def test_onearg_node_template(self):
        node = analytics.do_get_analytics(self.parser, self.token_onearg)
        self.assertEqual(node.template_name, 'google_analytics/test_template.html')
    
    def test_twoarg_node_exception(self):
        self.assertRaises(template.TemplateSyntaxError, analytics.do_get_analytics, self.parser, self.token_twoarg)

class NodeTest(TestCase):
    def setUp(self):
        self.node_noarg = analytics.AnalyticsNode()
        self.node_code = analytics.AnalyticsNode(code='UA-999999-1')
        self.node_explicit_template = analytics.AnalyticsNode(code='UA-999999-1', template_name='google_analytics/test_template.html')
        self.node_site = analytics.AnalyticsNode(site=None, template_name='google_analytics/test_template.html')
        self.node_code_and_site = analytics.AnalyticsNode(site=None, code='UA-999999-1', template_name='google_analytics/test_template.html')

    def test_default_template_name(self):
        self.assertEqual(self.node_noarg.template_name, 'google_analytics/analytics_template.html')

    def test_explicit_template_name(self):
        self.assertEqual(self.node_explicit_template.template_name, 'google_analytics/test_template.html')
        
    def test_noarg_code_name(self):
        self.assertEqual(self.node_noarg.code, '')
<commit_msg>Fixed failing noarg code name test.<commit_after>from django.test import TestCase
from django import template

from google_analytics.templatetags import analytics 

class ParserTest(TestCase):
    def setUp(self):
        self.parser = "unused"
        #################################
        # Pathological case - Do not test
        #self.token_null = template.Token(template.TOKEN_BLOCK, "")
        #################################

        self.token_noarg = template.Token(template.TOKEN_BLOCK, "test")
        self.token_onearg = template.Token(template.TOKEN_BLOCK, "test 'UA-888888-1'")
        self.token_twoarg = template.Token(template.TOKEN_BLOCK, "test 'UA-888888-1' 'UA-999999-2'")

    def test_setup(self):
        self.assert_(True)

    def test_basic_return(self):
        node = analytics.do_get_analytics(self.parser, self.token_noarg)
        self.assertTrue(isinstance(node, template.Node))

    def _test_null_node_template(self):
        node = analytics.do_get_analytics(self.parser, self.token_null)
        self.assertEqual(node.template_name, 'google_analytics/_template.html')

    def test_noarg_node_template(self):
        node = analytics.do_get_analytics(self.parser, self.token_noarg)
        self.assertEqual(node.template_name, 'google_analytics/test_template.html')
    
    def test_onearg_node_template(self):
        node = analytics.do_get_analytics(self.parser, self.token_onearg)
        self.assertEqual(node.template_name, 'google_analytics/test_template.html')
    
    def test_twoarg_node_exception(self):
        self.assertRaises(template.TemplateSyntaxError, analytics.do_get_analytics, self.parser, self.token_twoarg)

class NodeTest(TestCase):
    def setUp(self):
        self.node_noarg = analytics.AnalyticsNode()
        self.node_code = analytics.AnalyticsNode(code='UA-999999-1')
        self.node_explicit_template = analytics.AnalyticsNode(code='UA-999999-1', template_name='google_analytics/test_template.html')
        self.node_site = analytics.AnalyticsNode(site=None, template_name='google_analytics/test_template.html')
        self.node_code_and_site = analytics.AnalyticsNode(site=None, code='UA-999999-1', template_name='google_analytics/test_template.html')

    def test_default_template_name(self):
        self.assertEqual(self.node_noarg.template_name, 'google_analytics/analytics_template.html')

    def test_explicit_template_name(self):
        self.assertEqual(self.node_explicit_template.template_name, 'google_analytics/test_template.html')
        
    def test_noarg_code_name(self):
        self.assertEqual(self.node_noarg.code, None)

{'fraction_non_alphanumeric': 0.12562141491395792, 'fraction_numerical': 0.01606118546845124, 'mean_word_length': 4.257286432160804, 'pattern_counts': {'":': 0, '<': 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': '4658787', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1595, 'n_words': 212}