def test_get_found(self): r = TweetRepository() r.add(Tweet("Welcome")) tweet = r.get(0) #print(tweet) self.assertEqual(tweet.text, "Welcome") self.assertEqual(tweet.id, 0)
def test_auto_increment_of_ids(self): repository = TweetRepository() first_tweet = Tweet("a first tweet") repository.add(first_tweet) self.assertEqual(first_tweet.id, 1) second_tweet = Tweet("a second tweet") repository.add(second_tweet) self.assertEqual(second_tweet.id, 2)
def test_auto_increment_after_adding_a_tweet(self): tweet_repository = TweetRepository() tweet = Tweet("RAPH") tweet2 = Tweet("JOHN") tweet_repository.add(tweet) tweet_repository.add(tweet2) self.assertEqual(tweet.id, 1) self.assertEqual(tweet2.id, 2)
def test_instance_variables(self): # Create an instance of the `Repository` class with one tweet # we initialize first tweet = Tweet('Test tweet') repository = TweetRepository(tweet) # Check that the repository as a tweet_list parameter self.assertIsNotNone(repository.tweet_list) # Check that `repository` holds a dictionary self.assertIsInstance(repository.tweet_list, dict) """ Check that when creating a new `repository` instance, we could retrieve the tweet message """ self.assertEqual(repository.tweet_list[0], 'Test tweet')
def test_del_tweet(self): repo = TweetRepository() tweet = Tweet("my first tweet") new_tweet = repo.add(tweet) old_size = repo.tweets_count() tweet = repo.del_tweet(1) self.assertIsNotNone(tweet.id) new_size = repo.tweets_count() self.assertEqual(old_size - 1, new_size)
def test_new_tweet(self): repo = TweetRepository() old_size = repo.tweets_count() tweet = Tweet("my first tweet") self.assertIsNotNone(tweet.created_at) new_tweet = repo.add(tweet) self.assertIsNotNone(new_tweet.id) new_size = repo.tweets_count() self.assertEqual(old_size + 1, new_size)
def test_add_tweet(self): repository = TweetRepository() tweet = Tweet("a new tweet") repository.add(tweet) self.assertEqual(len(repository.tweets), 1)
def test_instance_variables(self): repository = TweetRepository() self.assertEqual(len(repository.tweets), 0)
def test_instance_variables(self): repository = TweetRepository() self.assertEqual(len(repository.tweets), 0) # check tweets is empty at repo creation self.assertIsInstance(repository.tweets, list) # check tweets is a list
def test_add_tweet(self): repository = TweetRepository() tweet = Tweet("I am a new tweet !") repository.add(tweet) self.assertEqual(len(repository.tweets), 1) # check tweet has been added to tweets
def test_init_return_empty_list(self): tweet_repository = TweetRepository() self.assertEqual(len(tweet_repository.tweets), 0)
def test_get_tweet(self): tweet_repository = TweetRepository() tweet = Tweet("RAPH") tweet_repository.add(tweet) self.assertEqual(tweet, tweet_repository.get(1)) self.assertIsNone(tweet_repository.get(2))
def test_add_a_tweet(self): tweet_repository = TweetRepository() tweet = Tweet("RAPH") tweet_repository.add(tweet) self.assertEqual(len(tweet_repository.tweets), 1)
def test_instance_variables(self): # Create an instance of the `repo` class with one argument repo = TweetRepository() # Check that `text` holds the content of the repo self.assertEqual(repo.tweets_count(), 3)
def test_repositories(self): r = TweetRepository() self.assertNotEqual(r, None)
def test_delet_found(self): r = TweetRepository() r.add(Tweet("Welcome")) r.delete(0) self.assertEqual(len(r.data), 0)
def test_get_tweet(self): repository = TweetRepository() tweet = Tweet("a new tweet") repository.add(tweet) self.assertEqual(tweet, repository.get(1)) self.assertIsNone(repository.get(2))
def test_add(self): r = TweetRepository() r.add(Tweet("Welcome")) self.assertEqual(len(r.data), 1)