コード例 #1
0
ファイル: lambda_test.py プロジェクト: rassamyjs/lambdata-20
class SocialMediaUserTests(unittest.TestCase):
    """Tests for the usage of Social Media Users in our Social Media Class"""
    def setUp(self):
        self.user1 = SocialMediaUser(name="Jimmy", location="France")
        self.user2 = SocialMediaUser(name="Craig", location="Kenya")
        self.user3 = SocialMediaUser(name="Nick", location="Nova Scotia")

    def test_name(self):
        """Testing the name attribute"""
        self.assertEqual(self.user1.name, "Jimmy")
        self.assertEqual(self.user2.name, "Craig")

    def test_location(self):
        """Testing the location attribute"""
        self.assertEqual(self.user1.location, "France")
        self.assertEqual(self.user2.location, "Kenya")

    def test_default_upvotes(self):
        """Testing default upvotes"""
        self.assertEqual(self.user3.upvotes, 0)

    def test_unpopular(self):
        """Testing is_popular method"""
        self.assertFalse(self.user3.is_popular())
        self.user3.recieve_upvotes(101)
        self.assertTrue(self.user3.is_popular())
コード例 #2
0
class SocialMediaUserTests(unittest.TestCase):
    """Tests for the usage of Social Media Users in our Social Media Class"""

    def setUp(self):
        self.user1 = SocialMediaUser(name='Jimmy', location='France')
        self.user2 = SocialMediaUser(name='Craig', location='Kenya')
        self.user3 = SocialMediaUser(name='Nick', location='Nova Scotia')

    def test_name(self):
        """Testing the name attribute"""
        self.assertEqual(self.user1.name, 'Jimmy')
        self.assertEqual(self.user2.name, 'Craig')

    def test_location(self):
        """Testing the location attribute"""
        self.assertEqual(self.user1.location, 'France')
        self.assertEqual(self.user2.location, 'Kenya')

    def test_default_upvotes(self):
        """Testing default upvotes"""
        self.assertEqual(self.user3.upvotes, 0)

    def test_unpopular(self):
        """Testing is popular method"""
        self.assertFalse(self.user3.is_popular())
        self.user3.receive_upvotes(randint(101, 10000))
        self.assertTrue(self.user3.is_popular())
コード例 #3
0
class SocialMediaUserTest(unittest.TestCase):
    """Tests the social media class"""
    def setUp(self):
        """Common default setup code that runs before our tests"""
        self.user1 = SocialMediaUser("Jimmy", "France")
        self.user2 = SocialMediaUser("Craig", "Kenya")
        self.user3 = SocialMediaUser("Nick", "Novia Scotia", upvotes=50)

    def test_name(self):
        """ This test if the name attribute was in fact assigned properly"""
        self.assertEqual(self.user1.name, "Jimmy")
        self.assertEqual(self.user2.name, "Craig")

    def test_unpopular_popular(self):
        """ This test if the is_popular method works as intended"""
        self.assertFalse(self.user3.is_popular())
        self.user3.receive_upvotes(randint(101, 1000))
        self.assertTrue(self.user3.is_popular())
コード例 #4
0
ファイル: lambda_test.py プロジェクト: rassamyjs/lambdata-20
 def setUp(self):
     self.user1 = SocialMediaUser(name="Jimmy", location="France")
     self.user2 = SocialMediaUser(name="Craig", location="Kenya")
     self.user3 = SocialMediaUser(name="Nick", location="Nova Scotia")
コード例 #5
0
 def test_popular(self):
     ''' Test that a user with >100 upvotes is popular '''
     user1 = SocialMediaUser('Jand')
     for _ in range(randint(101, 10000)):
         user1.recieve_upvote()
     self.assertEqual(user1.is_popular(), True)
コード例 #6
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.recieve_upvote()
     self.assertEqual(user1.is_popular(), False)
コード例 #7
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)
コード例 #8
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')
コード例 #9
0
 def setUp(self):
     self.user1 = SocialMediaUser(name='Jimmy', location='France')
     self.user2 = SocialMediaUser(name='Craig', location='Kenya')
     self.user3 = SocialMediaUser(name='Nick', location='Nova Scotia')
コード例 #10
0
 def setUp(self):
     """Common default setup code that runs before our tests"""
     self.user1 = SocialMediaUser("Jimmy", "France")
     self.user2 = SocialMediaUser("Craig", "Kenya")
     self.user3 = SocialMediaUser("Nick", "Novia Scotia", upvotes=50)