def test_tinyset(self): size = 4 data = list(_yield_name_and_cat(size, self.app)) eq_(len(data), size) # Names are unique. eq_(len(set(addonname for addonname, cat in data)), size) # Size is smaller than name list, so no names end in numbers. ok_(not any(addonname[-1].isdigit() for addonname, cat in data))
def test_bigset(self): size = 300 data = list(_yield_name_and_cat(size, self.app)) eq_(len(data), size) categories = collections.defaultdict(int) for addonname, cat in data: categories[cat] += 1 # Addons are spread between categories evenly - the difference # between the largest and smallest category is less than 2. ok_(max(categories.values()) - min(categories.values()) < 2) eq_(len(set(addonname for addonname, cat in data)), size)
def test_smallset(self): size = 60 data = list(_yield_name_and_cat(size, self.app)) eq_(len(data), size) # Addons are split up equally within each categories. categories = collections.defaultdict(int) for addonname, category in data: categories[category.slug] += 1 if self.app is None: length = len(themes_categories) else: length = len(addons_categories[self.app.short]) eq_(set(categories.values()), set([size / length])) eq_(len(set(addonname for addonname, cat in data)), size) ok_(not any(addonname[-1].isdigit() for addonname, cat in data))