@override_settings(
        ADV_CACHE_INCLUDE_PK = True,
    )
    def test_primary_key(self):
        """Test with ``ADV_CACHE_INCLUDE_PK`` set to ``True``."""

        # Reset CacheTag config with default value (from the ``override_settings``)
        self.reload_config()

        expected = "foobar"

        t = """
            {% load adv_cache %}
            {% cache 1 test_cached_template obj.pk obj.updated_at %}
                {{ obj.get_name }}
            {% endcache %}
        """

        # Render a first time, should miss the cache
        self.assertStripEqual(self.render(t), expected)
        self.assertEqual(self.get_name_called, 1)

        # Now the rendered template should be in cache

        # We add the pk as a part to the fragment name
        key = self.get_template_key(self.obj['pk'] % 'test_cached_template.%s',
                                    vary_on=[self.obj['pk'], self.obj['updated_at']])
        self.assertEqual(
            key, 'template.cache.test_cached_template.42.0cac9a03d5330dd78ddc9a0c16f01403')

        # It should be in the cache
        cache_expected = b"1::\n                foobar"
        self.assertStripEqual(get_cache('default').get(key), cache_expected)

        # Render a second time, should hit the cache
        self.assertStripEqual(self.render(t), expected)
        self.assertEqual(self.get_name_called, 1)  # Still 1
dataset/ETHPy150Open twidi/django-adv-cache-tag/adv_cache_tag/tests/tests.py/BasicTestCase.test_primary_key/swapped operands of `%`