Example #1
0
    def test_yield_query_adaptor(self):
        """
        Checks if YieldQueryAdaptor implements the claimed interface and the
        implementation is sane.
        """

        a_ia32 = Arch()
        a_ia32.name = "i386"

        a_amd64 = Arch()
        a_amd64.name = "x86_64"

        a_noarch = Arch()
        a_noarch.name = "noarch"

        self.db.session.add(a_ia32)
        self.db.session.add(a_amd64)
        self.db.session.add(a_noarch)
        self.db.session.flush()

        q = self.db.session.query(Arch)

        yqa = YieldQueryAdaptor(q, 1)

        self.assertEqual(len(yqa), 3)
        self.assertEqual([arch for arch in yqa], [a_ia32, a_amd64, a_noarch])
Example #2
0
    def get_ssources_for_retrace(self, db, max_fail_count=-1, yield_per=-1):
        """
        Return a list of pyfaf.storage.SymbolSource objects of given
        problem type that need retracing.
        If yield_per is greater than 0, the function returns an object that
        partially implements the list interface (__len__, __iter__).
        """

        q = self._get_ssources_for_retrace_query(db)
        if q is None:
            return []
        if max_fail_count >= 0:
            q = q.filter(SymbolSource.retrace_fail_count <= max_fail_count)
        if yield_per > 0:
            return YieldQueryAdaptor(q, yield_per)
        else:
            return q.all()