Beispiel #1
0
    def testRender(self):

        plugin = RotatingQuotes()
        instance = DummyInstance()
        data = plugin.render(DummyContext(), instance, DummyPlaceholder())

        quotes = data['quotes']
        next = data['next']

        self.failUnless(len(quotes)==instance.count)

        idx = -1
        for quote in quotes:
            a = int(quote.author)
            msg = "a: %d, idx: %d" % (a, idx)
            if idx >= 0:
                if a == 0:
                    self.failUnless(idx==(self.N-1), msg)
                else:
                    self.failUnless((a-idx) == 1, msg)
            idx = a

        last = int(quotes[-1].author)
        if last == self.N - 1:
            x = 0
        else:
            x = last+1

        self.failUnless(next == x, "next: %d, x: %d" % (next, x))
Beispiel #2
0
    def testRange(self):
        plugin = RotatingQuotes()
        instance = DummyInstance()
        for idx in range(20):
            q = {START_VAR: idx}
            data = plugin.render(DummyContext(q), instance, DummyPlaceholder())
            quotes = data['quotes']
            next = data['next']
            print "start: %d, next: %s" % (idx, next),
            print quotes

            self.failUnless(len(quotes)==instance.count)