def test_output(self):
     mock_stdout = MockPrint()
     o.get().print_function = mock_stdout.do_print
     o.get().echoed = ""
     o.get().echo("hello")
     o.get().echo("hi")
     self.assertEqual(o.get().echoed, mock_stdout.printed)
 def test_lastrepocommits(self):
     m.get().dest = set()
     mock_stdout = MockPrint()
     o.get().print_function = mock_stdout.do_print
     cli = gicowa.Cli(("--no-color", "lastrepocommits", "myRepo", "since", "2015", "10", "11",
                       "20", "08", "00"), MockGithubLib())
     cli.run()
     expected = "lastrepocommits myRepo since 2015-10-11 20:08:00\n" \
              + "Last commit pushed on 2015-10-11 20:22:24\n" \
              + "Committed on myDate - myCommitter - myMessage\n"
     actual = mock_stdout.printed
     self.assertEqual(actual, expected)
 def test_nocolor(self):
     m.get().dest = set()
     mock_stdout = MockPrint()
     o.get().print_function = mock_stdout.do_print
     cli = gicowa.Cli(("--no-color", "watchlist", "myUsername"), MockGithubLib())
     cli.run()
     expected = "watchlist myUsername\n" \
              + "mySubscription1\n" \
              + "mySubscription2\n" \
              + "mySubscription3\n"
     actual = mock_stdout.printed
     self.assertEqual(actual, expected)
 def test_mailto(self):
     mock_smtplib = MockSmtplib()
     m.get().smtplib = mock_smtplib
     o.get().echoed = ""
     cli = gicowa.Cli(("--no-color", "--mailto", "*****@*****.**", "watchlist",
                       "myUsername"), MockGithubLib())
     cli.run()
     expected = "watchlist myUsername\n" \
              + "mySubscription1\n" \
              + "mySubscription2\n" \
              + "mySubscription3\n" \
              + "\nSent from %s.\n" % (os.uname()[1])
     actual = mock_smtplib.smtp.sent
     self.assertIn(expected, actual)