def test_fortune_notifier(self, mock_load_config, mock_twitter, mock_open): """Assert that FortuneNotifier works""" mock_open.return_value = "config.yaml" def load_config(filename): if "config.yaml" in filename: return self.base_auth elif "statuses.yaml" in filename: return self.statuses mock_load_config.side_effect = load_config self.fortune_notifier = FortuneNotifier() mock_open.return_value = "statuses.yaml" self.fortune_notifier.generate_message() self.assertIn(self.fortune_notifier.message, ['Status1', 'Status2'])
def setUp(self, mock_load_config, mock_twitter, mock_open): mock_open.return_value = "config.yaml" self.base_auth = dict(consumer_key='consumer_key', consumer_secret='consumer_secret', access_token_key='access_token_key', access_token_secret='access_token_secret') self.statuses = dict(status=['Status1', 'Status2'], motd='I am the MOTD') def load_config(filename): if "config.yaml" in filename: return self.base_auth elif "statuses.yaml" in filename: return self.statuses mock_load_config.side_effect = load_config mock_twitter.return_value = True self.bot = TwitterNotifier() self.fortune_notifier = FortuneNotifier()