示例#1
0
    def test_detail_caching(self):
        url = '/{0}/117982/fr/foo'.format(self._prefix)
        cache_key = self.view._get_cache_key(117982, 'fr')

        with HTTMock(waypoint_detail_mock):
            cache_document_detail.delete(cache_key)
            cache_value = cache_document_detail.get(cache_key)
            self.assertEqual(cache_value, NO_VALUE)

            # check that the response is cached
            self.app.get(url, status=200)

            cache_value = cache_document_detail.get(cache_key)
            self.assertNotEqual(cache_value, NO_VALUE)

            # check that values are returned from the cache
            fake_cache_value = CachedPage('117982-fr-1', 'fake page')
            cache_document_detail.set(cache_key, fake_cache_value)

            response = self.app.get(url, status=200)
            self.assertEqual(response.text, 'fake page')

        # simulate that the version of the document in the api has changed
        with HTTMock(waypoint_detail_new_mock):
            response = self.app.get(url, status=200)
            self.assertNotEqual(response.text, 'fake page')
示例#2
0
    def test_detail_caching(self):
        url = "/{0}/117982/fr/foo".format(self._prefix)
        cache_key = self.view._get_cache_key(117982, "fr")

        with HTTMock(waypoint_detail_mock):
            cache_document_detail.delete(cache_key)
            cache_value = cache_document_detail.get(cache_key)
            self.assertEqual(cache_value, NO_VALUE)

            # check that the response is cached
            self.app.get(url, status=200)

            cache_value = cache_document_detail.get(cache_key)
            self.assertNotEqual(cache_value, NO_VALUE)

            # check that values are returned from the cache
            fake_cache_value = CachedPage("117982-fr-1", "fake page")
            cache_document_detail.set(cache_key, fake_cache_value)

            response = self.app.get(url, status=200)
            self.assertEqual(response.text, "fake page")

        # simulate that the version of the document in the api has changed
        with HTTMock(waypoint_detail_new_mock):
            response = self.app.get(url, status=200)
            self.assertNotEqual(response.text, "fake page")
示例#3
0
    def test_detail_caching(self):
        url = '/{0}/123/fr'.format(self._prefix)
        cache_key = self.view._get_cache_key(123, 'fr')

        with HTTMock(profile_info_mock):
            cache_document_detail.delete(cache_key)
            cache_value = cache_document_detail.get(cache_key)
            self.assertEqual(cache_value, NO_VALUE)

            # check that the response is cached
            self.app.get(url, status=200)

            cache_value = cache_document_detail.get(cache_key)
            self.assertNotEqual(cache_value, NO_VALUE)

            # check that values are returned from the cache
            fake_cache_value = CachedPage('123-fr-2', 'fake page')
            cache_document_detail.set(cache_key, fake_cache_value)

            response = self.app.get(url, status=200)
            self.assertEqual(response.text, 'fake page')

        # simulate that the version of the document in the api has changed
        with HTTMock(profile_info_new_mock):
            response = self.app.get(url, status=200)
            self.assertNotEqual(response.text, 'fake page')
示例#4
0
    def test_detail_caching_debug(self):
        """ Check that the cache is not used when using the debug flag.
        """
        url = '/{0}/117982/fr/foo?debug'.format(self._prefix)
        cache_key = self.view._get_cache_key(117982, 'fr')
        cache_document_detail.delete(cache_key)

        with HTTMock(waypoint_detail_mock):
            response = self.app.get(url, status=200)

            cache_value = cache_document_detail.get(cache_key)
            self.assertEqual(cache_value, NO_VALUE)
            self.assertIsNone(response.headers.get('ETag'))
示例#5
0
    def test_detail_caching_debug(self):
        """ Check that the cache is not used when using the debug flag.
        """
        url = "/{0}/117982/fr/foo?debug".format(self._prefix)
        cache_key = self.view._get_cache_key(117982, "fr")
        cache_document_detail.delete(cache_key)

        with HTTMock(waypoint_detail_mock):
            response = self.app.get(url, status=200)

            cache_value = cache_document_detail.get(cache_key)
            self.assertEqual(cache_value, NO_VALUE)
            self.assertIsNone(response.headers.get("ETag"))