Exemple #1
0
 def test_render_internal_ip(self):
     req = HttpRequest()
     req.META['REMOTE_ADDR'] = '1.1.1.1'
     context = Context({'request': req})
     r = WoopraNode().render(context)
     assert r.startswith('<!-- Woopra disabled on internal IP address')
     assert r.endswith('-->')
 def test_render_internal_ip(self):
     req = HttpRequest()
     req.META['REMOTE_ADDR'] = '1.1.1.1'
     context = Context({'request': req})
     r = WoopraNode().render(context)
     self.assertTrue(r.startswith(
             '<!-- Woopra disabled on internal IP address'), r)
     self.assertTrue(r.endswith('-->'), r)
 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 = WoopraNode().render(context)
     self.assertTrue(
         r.startswith('<!-- Woopra disabled on internal IP address'), r)
     self.assertTrue(r.endswith('-->'), r)
 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 = WoopraNode().render(context)
     self.assertTrue(r.startswith(
             '<!-- Woopra disabled on internal IP address'), r)
     self.assertTrue(r.endswith('-->'), r)
Exemple #5
0
 def test_no_identify_when_explicit_email(self):
     r = WoopraNode().render(
         Context({
             'woopra_email': 'explicit',
             'user': User(username='******')
         }))
     self.assertTrue('var woo_visitor = {"email": "explicit"};' in r, r)
Exemple #6
0
 def test_no_identify_when_explicit_name(self):
     r = WoopraNode().render(
         Context({
             'woopra_name': 'explicit',
             'user': User(username='******'),
         }))
     assert 'var woo_visitor = {"name": "explicit"};' in r
Exemple #7
0
 def test_custom(self):
     r = WoopraNode().render(
         Context({
             'woopra_var1': 'val1',
             'woopra_var2': 'val2',
         }))
     assert 'var woo_visitor = {"var1": "val1", "var2": "val2"};' in r
 def test_no_identify_when_explicit_email(self):
     self.settings_manager.set(ANALYTICAL_AUTO_IDENTIFY=True)
     r = WoopraNode().render(
         Context({
             'woopra_email': 'explicit',
             'user': User(username='******')
         }))
     self.assertTrue('var woo_visitor = {"email": "explicit"};' in r, r)
Exemple #9
0
 def test_identify_name_and_email(self):
     r = WoopraNode().render(
         Context({
             'user':
             User(username='******',
                  first_name='Firstname',
                  last_name='Lastname',
                  email="*****@*****.**"),
         }))
     assert 'var woo_visitor = '
     '{"email": "*****@*****.**", "name": "Firstname Lastname"};' in r
Exemple #10
0
 def test_identify_name_and_email(self):
     r = WoopraNode().render(
         Context({
             'user':
             User(username='******',
                  first_name='Firstname',
                  last_name='Lastname',
                  email="*****@*****.**")
         }))
     self.assertTrue(
         'var woo_visitor = {"name": "Firstname Lastname", '
         '"email": "*****@*****.**"};' in r, r)
 def test_identify_name_and_email(self):
     self.settings_manager.set(ANALYTICAL_AUTO_IDENTIFY=True)
     r = WoopraNode().render(
         Context({
             'user':
             User(username='******',
                  first_name='Firstname',
                  last_name='Lastname',
                  email="*****@*****.**")
         }))
     self.assertTrue(
         'var woo_visitor = {"name": "Firstname Lastname", '
         '"email": "*****@*****.**"};' in r, r)
 def test_idle_timeout(self):
     self.settings_manager.set(WOOPRA_IDLE_TIMEOUT=1234)
     r = WoopraNode().render(Context({}))
     self.assertTrue(
         'var woo_settings = {"domain": "example.com", '
         '"idle_timeout": "1234"};' in r, r)
Exemple #13
0
 def test_identify_anonymous_user(self):
     r = WoopraNode().render(Context({'user': AnonymousUser()}))
     self.assertTrue('var woo_visitor = {};' in r, r)
Exemple #14
0
 def test_identify_username_no_email(self):
     r = WoopraNode().render(Context({'user': User(username='******')}))
     self.assertTrue('var woo_visitor = {"name": "test"};' in r, r)
Exemple #15
0
 def test_idle_timeout(self):
     r = WoopraNode().render(Context({}))
     self.assertTrue(
         'var woo_settings = {"domain": "example.com", '
         '"idle_timeout": "1234"};' in r, r)
Exemple #16
0
 def test_node(self):
     r = WoopraNode().render(Context({}))
     self.assertTrue('var woo_settings = {"domain": "example.com"};' in r,
                     r)
Exemple #17
0
 def test_wrong_domain(self):
     with pytest.raises(AnalyticalException):
         WoopraNode()
 def test_identify_username_no_email(self):
     self.settings_manager.set(ANALYTICAL_AUTO_IDENTIFY=True)
     r = WoopraNode().render(Context({'user': User(username='******')}))
     self.assertTrue('var woo_visitor = {"name": "test"};' in r, r)