Esempio n. 1
0
class ReportTestCase(TestCase):
    fixtures = ['test_data.yaml']

    def setUp(self):
        mcache.clear()

        self.user = User.objects.get(id=1)
        self.client.login(username='******', password='******')

        self.request = Object()
        self.request.user = self.user
        self.request.session = self.client.session

        self.report = Report()
        self.report.scope = Scope()
        self.report.perspective = Perspective()

    def test_resolve_caching(self):
        session = self.request.session

        self.report.resolve(self.request, 'html')
        cache = session[Report.REPORT_CACHE_KEY]
        ts1 = cache['timestamp']

        self.report.resolve(self.request, 'html')
        ts2 = cache['timestamp']

        self.report.resolve(self.request, 'html', page_num=100)
        ts3 = cache['timestamp']

        self.report.resolve(self.request, 'html', per_page=1)
        ts4 = cache['timestamp']

        self.report.resolve(self.request, 'html', per_page=1, page_num=1)
        ts5 = cache['timestamp']
Esempio n. 2
0
    def setUp(self):
        mcache.clear()

        self.user = User.objects.get(id=1)
        self.client.login(username='******', password='******')

        self.request = Object()
        self.request.user = self.user
        self.request.session = self.client.session

        self.report = Report()
        self.report.scope = Scope()
        self.report.perspective = Perspective()