def testAffinity(self):
        self.addComponent('foo:r', '/localhost@rpl:branch/1.0-1-1', '!readline',
                          ['/usr/bin/foo'])
        self.addComponent('foo:r', '/localhost@rpl:branch/2.0-1-1', 
                          'readline,~!ssl', ['/usr/bin/foo'])
        self.addComponent('foo:r', '/localhost@rpl:branch/2.0-1-1', 
                          'readline,~ssl', ['/usr/bin/foo'])
        self.addComponent('foo:r', '/localhost@rpl:branch/2.0-1-1', 
                          '!readline,~ssl', ['/usr/bin/foo'])
        self.addComponent('foo:r', '/localhost@rpl:branch/2.0-1-1', 
                          '!readline,~!ssl', ['/usr/bin/foo'])

        # orig branch - found by very few queries
        self.addComponent('foo:r', 
                          '/localhost@rpl:linux/1.0-1-1', 'readline')
        self.updatePkg('foo:r=:branch/1.0[!readline]')

        repos = self.openRepository()

        def _get(affinityDb, versionFilter, flavorFilter, troveSpec):
            return queryrep.getTrovesToDisplay(repos, troveSpec, [], [],
                                               versionFilter,
                                               flavorFilter, 
                                               self.cfg.installLabelPath,
                                               self.cfg.flavor, affinityDb)

        db = self.openDatabase()
        troveTups = _get(db, VERSION_FILTER_LATEST, 
                         FLAVOR_FILTER_BEST, ['foo:r'])
        assert(len(troveTups) == 1)
        assert(troveTups[0][1].branch() == VFS('/localhost@rpl:branch'))
        assert(str(troveTups[0][2]) == '!readline,~ssl')

        troveTups = _get(db, VERSION_FILTER_LATEST, 
                         FLAVOR_FILTER_AVAIL, ['foo:r'])

        assert(len(troveTups) == 2)
        flavors = set(str(x[2]) for x in troveTups)
        assert(flavors in 'readline,~ssl')
        assert('!readline,~ssl' in flavors)

        # system compatible, should ignore db
        troveTups = _get(None, VERSION_FILTER_LATEST, 
                         FLAVOR_FILTER_AVAIL, ['foo:r'])

        assert(len(troveTups) == 1)
        assert(troveTups[0][1].branch() == VFS('/localhost@rpl:linux'))
        flavors = set(str(x[2]) for x in troveTups)
        assert('readline' in flavors)
dataset/ETHPy150Open sassoftware/conary/conary_test/queryreptest.py/RepQueryTest.testAffinity/swapped operands of `in`