def test_get_status(self):
        url = self.url_for(DemoCacheResource.endpoint_for_action(DemoCacheResource.Action.GET_STATUS))

        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        content = self.extract_response_content(resp)
        self.assertTrue(content)

        dogpile_cache_ext.disable_cache()
        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        content = self.extract_response_content(resp)
        self.assertIn('cache_enabled', content)
        self.assertFalse(content['cache_enabled'])
    def test_get_cached_current_time(self):
        url = self.url_for(DemoCacheResource.endpoint_for_action(DemoCacheResource.Action.GET_CACHED_CURRENT_TIME))

        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        current_time_1 = self.extract_response_content(resp)
        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        current_time_2 = self.extract_response_content(resp)
        self.assertEqual(current_time_1, current_time_2)

        dogpile_cache_ext.disable_cache()
        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        current_time_3 = self.extract_response_content(resp)
        self.assertNotEqual(current_time_2, current_time_3)
    def test_cache_key_change(self):
        url = self.url_for(DemoCacheResource.endpoint_for_action(DemoCacheResource.Action.GET_CACHED_CURRENT_TIME))

        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        current_time_1 = self.extract_response_content(resp)
        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        current_time_2 = self.extract_response_content(resp)
        self.assertEqual(current_time_1, current_time_2)

        # Changing the Git revision value should impact the generation of the response data cache key
        git_revision = current_app.config.get('GIT_REVISION')
        current_app.config['GIT_REVISION'] = 'changed'

        resp = self.client_get(url)
        self.assert200(resp, resp.data)
        current_time_3 = self.extract_response_content(resp)
        self.assertNotEqual(current_time_2, current_time_3)

        # Restore the original git revision value
        current_app.config['GIT_REVISION'] = git_revision
 def test_disable(self):
     url = self.url_for(DemoCacheResource.endpoint_for_action(DemoCacheResource.Action.DISABLE))
     resp = self.client_post(url)
     self.assert200(resp, resp.data)
     self.assertFalse(dogpile_cache_ext.is_cache_enabled(current_app))