Example #1
0
    def test_get_version_caching(self):
        headers = self.add_authorization_header(username='******')
        url = '{0}/{1}/en/{2}'.format(
                self._prefix, str(self.xreport1.document_id),
                str(self.xreport1_version.id))
        cache_key = '{0}-{1}'.format(
            get_cache_key(self.xreport1.document_id, 'en'),
            self.xreport1_version.id)

        cache_value = cache_document_version.get(cache_key)
        self.assertEqual(cache_value, NO_VALUE)

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

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

        # check that values are returned from the cache
        fake_cache_value = {'document': 'fake doc'}
        cache_document_version.set(cache_key, fake_cache_value)

        response = self.app.get(url, headers=headers, status=200)
        body = response.json
        self.assertEqual(body, fake_cache_value)
Example #2
0
    def test_get_version_caching(self):
        headers = self.add_authorization_header(username='******')
        url = '{0}/{1}/en/{2}'.format(self._prefix,
                                      str(self.xreport1.document_id),
                                      str(self.xreport1_version.id))
        cache_key = '{0}-{1}'.format(
            get_cache_key(self.xreport1.document_id, 'en'),
            self.xreport1_version.id)

        cache_value = cache_document_version.get(cache_key)
        self.assertEqual(cache_value, NO_VALUE)

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

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

        # check that values are returned from the cache
        fake_cache_value = {'document': 'fake doc'}
        cache_document_version.set(cache_key, fake_cache_value)

        response = self.app.get(url, headers=headers, status=200)
        body = response.json
        self.assertEqual(body, fake_cache_value)
Example #3
0
    def test_get_version_caching(self):
        url = '{0}/{1}/en/{2}'.format(self._prefix,
                                      str(self.book1.document_id),
                                      str(self.book1_version.id))
        cache_key = '{0}-{1}'.format(
            get_cache_key(self.book1.document_id, 'en'), self.book1_version.id)

        cache_value = cache_document_version.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_version.get(cache_key)
        self.assertNotEqual(cache_value, NO_VALUE)

        # check that values are returned from the cache
        fake_cache_value = {'document': 'fake doc'}
        cache_document_version.set(cache_key, fake_cache_value)

        response = self.app.get(url, status=200)
        body = response.json
        self.assertEqual(body, fake_cache_value)
Example #4
0
    def test_get_version_caching(self):
        url = '{0}/{1}/en/{2}'.format(
                self._prefix, str(self.book1.document_id),
                str(self.book1_version.id))
        cache_key = '{0}-{1}'.format(
            get_cache_key(self.book1.document_id, 'en'),
            self.book1_version.id)

        cache_value = cache_document_version.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_version.get(cache_key)
        self.assertNotEqual(cache_value, NO_VALUE)

        # check that values are returned from the cache
        fake_cache_value = {'document': 'fake doc'}
        cache_document_version.set(cache_key, fake_cache_value)

        response = self.app.get(url, status=200)
        body = response.json
        self.assertEqual(body, fake_cache_value)