def test_simple_select_ignorelist(self): sys.argv = [self.program_name, '--ignore_list', 'test'] main() yatcobot.cli.TwitterConfig.load.assert_called_once_with('config.yaml') yatcobot.cli.Yatcobot.assert_called_once_with('test') self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
def test_simple_select_ignorelist(self): sys.argv = [self.program_name, '--ignore_list', 'test'] main() yatcobot.cli.Config.load.assert_called_once_with(('config.json')) yatcobot.cli.Yatcobot.assert_called_once_with('test') self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
def test_simple_select_config(self): sys.argv = [self.program_name, '--config', 'test.json'] main() yatcobot.cli.Config.load.assert_called_once_with('test.json') yatcobot.cli.Yatcobot.assert_called_once_with('ignorelist') self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
def test_simple_debug(self): sys.argv = [self.program_name, '--debug'] yatcobot.cli.create_logger = MagicMock() main() yatcobot.cli.Config.load.assert_called_once_with(('config.json')) yatcobot.cli.Yatcobot.assert_called_once_with('ignorelist') yatcobot.cli.create_logger.assert_called_once_with(logging.DEBUG, None) self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
def test_simple_debug(self): sys.argv = [self.program_name, '--debug'] yatcobot.cli.create_logger = MagicMock() main() yatcobot.cli.TwitterConfig.load.assert_called_once_with('config.yaml') yatcobot.cli.Yatcobot.assert_called_once_with('ignorelist') yatcobot.cli.create_logger.assert_called_once_with(logging.DEBUG, None) self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
def test_email(self): sys.argv = [self.program_name, '--test-mail'] test_function_mock = MagicMock() yatcobot.cli.MailNotifier.test = test_function_mock NotifiersConfig.get()['mail']['enabled'] = True with self.assertRaises(SystemExit): main() self.assertEqual(test_function_mock.call_count, 1)
def test_simple_select_log(self): sys.argv = [self.program_name, '--log', 'test'] yatcobot.cli.create_logger = MagicMock() main() yatcobot.cli.Config.load.assert_called_once_with(('config.json')) yatcobot.cli.Yatcobot.assert_called_once_with('ignorelist') yatcobot.cli.create_logger.assert_called_once_with( logging.INFO, 'test') self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
def test_email(self): sys.argv = [self.program_name, '--test-mail'] notifier_mock = MagicMock() yatcobot.cli.MailNotifier = notifier_mock with self.assertRaises(SystemExit): main() self.assertEqual( notifier_mock.from_config.return_value.test.call_count, 1)
def test_login(self): sys.argv = [self.program_name, '--login'] yatcobot.cli.create_logger = MagicMock() yatcobot.cli.get_access_token = MagicMock(return_value={'token': 'test', 'secret': 'test'}) builtins.input = MagicMock(return_value='y') main() yatcobot.cli.Config.save_user_tokens.assert_called_once_with('config.json', 'test', 'test') yatcobot.cli.Config.load.assert_called_once_with(('config.json')) yatcobot.cli.Yatcobot.assert_called_once_with('ignorelist') yatcobot.cli.create_logger.assert_called_once_with(logging.INFO, None) self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
def test_login(self): sys.argv = [self.program_name, '--login'] yatcobot.cli.create_logger = MagicMock() yatcobot.cli.get_access_token = MagicMock(return_value={ 'token': 'test', 'secret': 'test' }) builtins.input = MagicMock(return_value='y') main() yatcobot.cli.Config.save_user_tokens.assert_called_once_with( 'config.json', 'test', 'test') yatcobot.cli.Config.load.assert_called_once_with(('config.json')) yatcobot.cli.Yatcobot.assert_called_once_with('ignorelist') yatcobot.cli.create_logger.assert_called_once_with(logging.INFO, None) self.assertTrue(yatcobot.cli.Yatcobot.return_value.run.called)
#!/usr/bin/env python3 from yatcobot.cli import main main()