Exemplo n.º 1
0
 def test_unpopular(self):
     """Test that a user with <=100 upvotes is not popular."""
     new_user = SocialMediaUser('Bryce', 'US')
     self.assertFalse(new_user.is_popular())
     for _ in range(randint(1, 100)):
         new_user.receive_upvote()
     self.assertFalse(new_user.is_popular())
Exemplo n.º 2
0
 def test_popular(self):
     """Test that a user with >100 upvotes is popular."""
     user1 = SocialMediaUser('Jane')
     for _ in range(randint(101, 10000)):
         user1.receive_upvote()
     self.assertEqual(user1.is_popular(), True)
Exemplo n.º 3
0
 def test_unpopular(self):
     """Test that a user with <=100 upvotes is not popular."""
     user1 = SocialMediaUser('Joe')
     for _ in range(randint(1, 100)):
         user1.receive_upvote()
     self.assertEqual(user1.is_popular(), False)
Exemplo n.º 4
0
 def test_default_upvotes(self):
     """Test that the default upvotes of a new user is 0."""
     user1 = SocialMediaUser('Jane')
     self.assertEqual(user1.upvotes, 0)
Exemplo n.º 5
0
 def test_name(self):
     """Test that the name field is assigned correctly."""
     user1 = SocialMediaUser('Jane')
     user2 = SocialMediaUser('Joe')
     self.assertEqual(user1.name, 'Jane')
     self.assertEqual(user2.name, 'Joe')
Exemplo n.º 6
0
 def test_default_upvotes(self):
     new_user = SocialMediaUser('Maria', 'Spain')
     self.assertEqual(new_user.upvotes, 0)
Exemplo n.º 7
0
 def setUp(self):
     """Common set up code run before all tests."""
     self.user1 = SocialMediaUser('Jane', 'Denmark')
     self.user2 = SocialMediaUser('Joe', 'Russia')
Exemplo n.º 8
0
 def test_popular(self):
     """Test that a user with >100 upvotes is popular."""
     new_user = SocialMediaUser('Jack', 'US')
     for _ in range(randint(101, 10000)):
         new_user.receive_upvote()
     self.assertTrue(new_user.is_popular())
Exemplo n.º 9
0
 def test_default_upvotes(self):
     """Tests that the default upvote value is 0"""
     new_user = SocialMediaUser('Mary', 'Spain')
     self.assertEqual(new_user.upvotes, 0)
Exemplo n.º 10
0
 def test_name(self):
     user1 = SocialMediaUser('Jane')
     user2 = SocialMediaUser('Joe')
     self.assertEqual(user1.name, 'Jane')
     self.assertEqual(user2.name, 'Joe')