def test_record_last_tweet_ok(self): tweets = [{"datetime":2013, "id":42}, {"datetime":2014, "id":43}, {"datetime":2012, "id":44}] path = "test/last_tweet.log" twemail = Twemail() twemail.record_last_tweet_id(tweets, path) with open(path, "r") as log: self.assertEqual(log.read(), '{"last_tweet_id": 43, "version": 1}')
def test_record_last_tweet_no_tweets(self): path = "test/last_tweet.log" with open(path, 'w'): #clear file pass twemail = Twemail() twemail.record_last_tweet_id([], path) with open(path, "r") as log: self.assertEqual(log.read(), '')