예제 #1
0
 def test_render_internal_ip(self):
     req = HttpRequest()
     req.META['REMOTE_ADDR'] = '1.1.1.1'
     context = Context({'request': req})
     r = MixpanelNode().render(context)
     assert r.startswith('<!-- Mixpanel 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 = MixpanelNode().render(context)
     self.assertTrue(r.startswith(
             '<!-- Mixpanel 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 = MixpanelNode().render(context)
     self.assertTrue(r.startswith(
             '<!-- Mixpanel disabled on internal IP address'), r)
     self.assertTrue(r.endswith('-->'), r)
예제 #4
0
 def test_event(self):
     r = MixpanelNode().render(
         Context({
             'mixpanel_event': ('test_event', {
                 'prop1': 'val1',
                 'prop2': 'val2'
             })
         }))
     self.assertTrue(
         "mixpanel.track('test_event', "
         '{"prop1": "val1", "prop2": "val2"});' in r, r)
예제 #5
0
 def test_identify_anonymous_user(self):
     r = MixpanelNode().render(Context({'user': AnonymousUser()}))
     assert "mixpanel.register_once({distinct_id:" not in r
예제 #6
0
 def test_identify(self):
     r = MixpanelNode().render(Context({'user': User(username='******')}))
     assert "mixpanel.identify('test');" in r
예제 #7
0
 def test_token_too_short(self):
     with pytest.raises(AnalyticalException):
         MixpanelNode()
예제 #8
0
 def test_no_token(self):
     with pytest.raises(AnalyticalException):
         MixpanelNode()
예제 #9
0
 def test_node(self):
     r = MixpanelNode().render(Context())
     assert "mixpanel.init('0123456789abcdef0123456789abcdef');" in r
 def test_identify(self):
     self.settings_manager.set(ANALYTICAL_AUTO_IDENTIFY=True)
     r = MixpanelNode().render(Context({'user': User(username='******')}))
     self.assertTrue("mpq.push(['identify', 'test']);" in r, r)
 def test_node(self):
     r = MixpanelNode().render(Context())
     self.assertTrue(
             "mpq.push(['init', '0123456789abcdef0123456789abcdef']);" in r,
             r)
예제 #12
0
 def test_identify(self):
     r = MixpanelNode().render(Context({'user': User(username='******')}))
     self.assertTrue("mixpanel.register_once({distinct_id: 'test'});" in r,
                     r)
예제 #13
0
 def test_identify_anonymous_user(self):
     r = MixpanelNode().render(Context({'user': AnonymousUser()}))
     self.assertFalse("mpq.push(['identify', " in r, r)
예제 #14
0
 def test_identify(self):
     r = MixpanelNode().render(Context({'user': User(username='******')}))
     self.assertTrue("mpq.push(['identify', 'test']);" in r, r)
예제 #15
0
 def test_node(self):
     r = MixpanelNode().render(Context())
     self.assertIn(
         "mixpanel.init('0123456789abcdef0123456789abcdef');",
         r,
     )