

def test_sites_contrib(self):
    site_one = Site.objects.get(pk=1)
    site_two = Site(domain='some.com', name='some.com')
    site_two.save()
    site_two_code = Keycode(site=site_two, provider='google', keycode='222')
    site_two_code.save()
    self.assertIn('222', ('%s' % site_two_code))
    tpl = '{% load sitemetrics %}{% sitemetrics %}'
    with override_settings(SITE_ID=1):
        self.assertEqual(render_string(tpl), '')
        site_one_code = Keycode(site=site_one, provider='yandex', keycode='111', active=False)
        site_one_code.save()
        site_one.assertEqual(render_string(tpl), '')
        site_one_code.active = True
        site_one_code.save()
        self.assertIn('111', render_string(tpl))
        self.assertIn('111', render_string(tpl))
    with override_settings(SITE_ID=2):
        self.assertIn('222', render_string(tpl))

dataset/ETHPy150Open idlesign/django-sitemetrics/sitemetrics/tests.py TemplateTagsTest.test_sites_contrib/VarMisuse@131/208 `self`->`site_one`