def test_hash(self): """ Test Meme class __hash__ method """ A = memesites.Meme('1', '2') B = memesites.Meme('1', '3') C = memesites.Meme('1', '2') D = memesites.Meme('2', '3') self.assertTrue(len(set([A, B, C, D])) == 3)
def test_ne(self): """ Test Meme class __ne__ method """ A = memesites.Meme('1', '2') B = memesites.Meme('1', '3') C = memesites.Meme('1', '2') D = memesites.Meme('2', '3') self.assertFalse(A != A and B != B and C != C and D != D) self.assertFalse(A != C) self.assertTrue(A != B) self.assertTrue(A != D) self.assertTrue(B != D)
def test_eq(self): """ Test Meme class equality """ A = memesites.Meme('1', '2') B = memesites.Meme('1', '3') C = memesites.Meme('1', '2') D = memesites.Meme('2', '3') self.assertTrue(A == A and B == B and C == C and D == D) self.assertTrue(A == C) self.assertFalse(A == B) self.assertFalse(A == D) self.assertFalse(B == D)
def test_init(self): """ Test the initialization routine of Meme class """ A = memesites.Meme('1', '2') self.assertTrue(A.get_pic_url() == '1') self.assertTrue(A.get_time() == '2') self.assertTrue(A.get_caption() is None) self.assertTrue(A.get_origin() == memesites.Origins.NA) self.assertTrue(A.get_tags() == [])
def mock_get_memes(*args, **kwargs): """ Mock function for the get_memes function Create a phony list of Memes """ a = [] for i in range(args[0]): a.append( memesites.Meme(i, datetime.datetime.now(), caption=str(i), raw_pic_url=str(i), origin=memesites.Origins.NA, tags=[], score=i)) return a