def test_verify_txmbr(self): pr = Mock() tx = Mock() tx.po = 'openssl' cb = RPMCallback(pr) # test cb.verify_txmbr(None, tx, 10) # validation pr.set_action.assert_called_with('Verifying', tx.po)
def test_errorlog(self): pr = ProgressReport() pr._updated = Mock() # test cb = RPMCallback(pr) message = 'Something bad happened' cb.errorlog(message) # validation self.assertEqual(pr.details['error'], message) self.assertEqual(len(pr.steps), 0)
def test_filelog(self): pr = ProgressReport() pr._updated = Mock() # test and validation cb = RPMCallback(pr) for action in sorted(cb.fileaction.keys()): package = '%s_package' % action cb.filelog(package, action) self.assertEqual(pr.details['action'], cb.fileaction[action]) self.assertEqual(pr.details['package'], package) self.assertEqual(len(pr.steps), 0)
def test_event(self): package = 'openssl' pr = Mock() # test and validation cb = RPMCallback(pr) expected_actions = set() for action, description in cb.action.items(): cb.event(package, action) cb.event(package, action) # test 2nd (dup) ignored expected_actions.add((package, action)) self.assertEqual(cb.events, expected_actions) pr.set_action.assert_called_with(description, package)
def test_filelog_invalid_action(self): pr = ProgressReport() pr._updated = Mock() # test cb = RPMCallback(pr) package = 'openssl' action = 12345678 cb.filelog(package, action) # validation self.assertEqual(pr.details['action'], str(action)) self.assertEqual(pr.details['package'], package) self.assertEqual(len(pr.steps), 0)