def test_report_changes_to_make(self): data = { 'keep-not-watching': ['keep/not.watching'], 'keep-watching': ['keep/watching'], 'watch': ['start/watching'], 'unwatch': ['stop/watching']} cmd = UpdateCommand(StubConfig()) cmd.report_changes_to_make(data) self.stdout.seek(0) self.assertMultiLineEqual( '\n'.join(( 'NO SUBSCRIPTION CHANGES:', ' - keep not watching: keep/not.watching', ' - keep watching: keep/watching', '', 'SUBSCRIPTION CHANGES:', ' - add subscription: start/watching', ' - remove subscription: stop/watching', '', 'SUMMARY:', ' - Keep watching: 1', ' - Keep not watching: 1', ' - Start watching: 1', ' - Stop watching: 1', '')), self.stdout.read())
def test_confirm_subscription_changes_with_no(self): self.type_when_asked('no') # python2.6 does not raise SystemExit exit = self.mocker.replace('sys.exit') self.expect(exit(1)).throw(SystemExit()) self.mocker.replay() cmd = UpdateCommand(StubConfig()) with self.assertRaises(SystemExit): cmd.confirm_subscription_changes()
def test_confirm_subscription_changes_with_yes(self): self.type_when_asked('yes') self.mocker.replay() cmd = UpdateCommand(StubConfig()) self.assertTrue(cmd.confirm_subscription_changes())