def test_display_units_over_threshold(self): # Test copied_modules = self._generate_errata(7) units_display.display_units(self.prompt, copied_modules, 2) # Verify expected_tags = ['summary', 'count-entry'] self.assertEqual(expected_tags, self.prompt.get_write_tags()) self.assertTrue('7' in self.recorder.lines[1])
def test_display_distribution(self): # Setup units = self._generate_distributions(1) # Test units_display.display_units(self.prompt, units, 100) # ensure that only the "id" of a distribution is being displayed self.assertEqual(self.recorder.lines[1].strip(), units[0]['unit_key']['id'])
def test_display_units_sort_units(self): # Setup units = self._generate_packages(10, TYPE_ID_RPM) # will be in descending order # Test units_display.display_units(self.prompt, units, 100) # Verify they were written out in ascending order for i in range(1, 10): self.assertTrue(str(i) in self.recorder.lines[i + 1])
def succeeded(self, task): """ It would seem to make sense that each subclass would define its own version of succeeded to properly format the list of units for its specific type. However, it's possible multiple types were copied at the same time, despite the fact that the commands are scoped to a type (ex: recursively copying a package group). The simplest approach is for this handling to be done here in the base class so that every subclass can display every type. """ copied_units = task.result # entries are a dict containing unit_key and type_id units_display.display_units(self.prompt, copied_units, self.unit_threshold)
def test_display_units_mixed(self): # Setup units = self._generate_packages(1, TYPE_ID_RPM) + \ self._generate_packages(1, TYPE_ID_SRPM) + \ self._generate_errata(1) + \ self._generate_distributions(1) + \ self._generate_drpms(1) + \ self._generate_package_category(1) + \ self._generate_package_groups(1) # Test units_display.display_units(self.prompt, units, 100) # Verify expected_tags = ['header'] for i in sorted([TYPE_ID_DISTRO, TYPE_ID_DRPM, TYPE_ID_ERRATA, TYPE_ID_PKG_CATEGORY, TYPE_ID_PKG_GROUP, TYPE_ID_RPM, TYPE_ID_SRPM]): expected_tags.append('type-header-%s' % i) expected_tags.append('unit-entry-%s' % i) self.assertEqual(expected_tags, self.prompt.get_write_tags())
def test_display_units_zero_count(self): # Test units_display.display_units(self.prompt, [], 10) # Verify self.assertEqual(['too-few'], self.prompt.get_write_tags())
def succeeded(self, task): removed_units = task.result # entries are a dict containing unit_key and type_id units_display.display_units(self.prompt, removed_units, self.unit_threshold)