def test_requires_update_ents_with_no_pool(self): pooltype_cache = PoolTypeCache() pooltype_cache.ent_dir = self.ent_dir for ent in self.ent_dir.certs: ent.pool = None # No ents have pools so there is nothing we can update self.assertFalse(pooltype_cache.requires_update())
def test_requires_update(self): pooltype_cache = PoolTypeCache() pooltype_cache.ent_dir = self.ent_dir # Doesn't have data for pool with id 'someid' self.assertTrue(pooltype_cache.requires_update()) pooltype_cache.pooltype_map['someid'] = 'some type' # After adding data for that entitlements pool, it shouldn't need an update self.assertFalse(pooltype_cache.requires_update())
def test_update(self): pooltype_cache = PoolTypeCache() pooltype_cache.ent_dir = self.ent_dir self.cp.getEntitlementList.return_value = [ self._build_ent_json('poolid', 'some type'), self._build_ent_json('poolid2', 'some other type')] # requires_update should be true, and should allow this method # to generate a correct mapping pooltype_cache.update() self.assertEqual(2, len(pooltype_cache.pooltype_map)) self.assertEqual('some type', pooltype_cache.get('poolid')) self.assertEqual('some other type', pooltype_cache.get('poolid2'))