Exemple #1
0
 def test_render_internal_ip(self):
     req = HttpRequest()
     req.META['REMOTE_ADDR'] = '1.1.1.1'
     context = Context({'request': req})
     r = ClickyNode().render(context)
     assert r.startswith('<!-- Clicky disabled on internal IP address')
     assert r.endswith('-->')
 def test_render_internal_ip(self):
     self.settings_manager.set(ANALYTICAL_INTERNAL_IPS=['1.1.1.1'])
     req = HttpRequest()
     req.META['REMOTE_ADDR'] = '1.1.1.1'
     context = Context({'request': req})
     r = ClickyNode().render(context)
     self.assertTrue(
         r.startswith('<!-- Clicky disabled on internal IP address'), r)
     self.assertTrue(r.endswith('-->'), r)
 def test_custom(self):
     r = ClickyNode().render(
         Context({
             'clicky_var1': 'val1',
             'clicky_var2': 'val2'
         }))
     self.assertTrue(
         re.search(
             'var clicky_custom = {.*'
             '"var1": "val1", "var2": "val2".*};', r), r)
 def test_identify(self):
     self.settings_manager.set(ANALYTICAL_AUTO_IDENTIFY=True)
     r = ClickyNode().render(Context({'user': User(username='******')}))
     self.assertTrue(
         'var clicky_custom = {"session": {"username": "******"}};' in r, r)
 def test_node(self):
     r = ClickyNode().render(Context({}))
     self.assertTrue('var clicky_site_id = 12345678;' in r, r)
     self.assertTrue('src="//in.getclicky.com/12345678ns.gif"' in r, r)
Exemple #6
0
 def test_custom(self):
     r = ClickyNode().render(Context({
         'clicky_var1': 'val1',
         'clicky_var2': 'val2',
     }))
     assert re.search(r'var clicky_custom = {.*"var1": "val1", "var2": "val2".*};', r)
Exemple #7
0
 def test_identify_anonymous_user(self):
     r = ClickyNode().render(Context({'user': AnonymousUser()}))
     assert 'var clicky_custom = {"session": {"username":' not in r
Exemple #8
0
 def test_identify(self):
     r = ClickyNode().render(Context({'user': User(username='******')}))
     assert 'var clicky_custom = {"session": {"username": "******"}};' in r
Exemple #9
0
 def test_wrong_site_id(self):
     with pytest.raises(AnalyticalException):
         ClickyNode()
Exemple #10
0
 def test_node(self):
     r = ClickyNode().render(Context({}))
     assert 'clicky_site_ids.push(12345678);' in r
     assert 'src="//in.getclicky.com/12345678ns.gif"' in r