コード例 #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('-->')
コード例 #2
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)
     self.assertTrue(r.startswith(
             '<!-- Mixpanel disabled on internal IP address'), r)
     self.assertTrue(r.endswith('-->'), r)
コード例 #3
0
 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
コード例 #10
0
 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)
コード例 #11
0
 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,
     )