Пример #1
0
 def test_get_resource_path_post(self):
     #
     # Create user
     #
     user = User.objects.create_user('broak', '*****@*****.**', 'abc123',
                                     name='Broak')
     #
     # Create meme
     #
     meme = Meme()
     meme.code = 'bla'
     meme.name = 'Bla'
     meme.owner = user
     meme.save()
     #
     # Create post
     #
     post = Post()
     post.owner = user
     post.meme = meme
     post.header = 'Flus'
     post.footer = 'Flis'
     post.save()
     #
     # Test resource path
     #
     path = utils.get_resource_path(post)
     self.assertEqual(path, '/posts/{}.{}'.format(post.pk,
                                                  settings.API_FORMAT))
Пример #2
0
 def test_like_unicode(self):
     #
     # Create user
     #
     user = User.objects.create_user('user', '*****@*****.**', 'Pwd007',
                                     name='User')
     #
     # Create meme
     #
     meme = Meme()
     meme.code = 'testmeme'
     meme.name = 'Test Meme'
     meme.owner = user
     meme.save()
     #
     # Create post
     #
     post = Post()
     post.header = 'HeaderText'
     post.meme = meme
     post.footer = 'FooterText'
     post.owner = user
     post.save()
     #
     # Create like
     #
     like = Like()
     like.owner = user
     like.post = post
     like.save()
     #
     # Test
     #
     self.assertEqual(unicode(like), '{} -> {}'.format(unicode(user),
                                                       unicode(post)))
Пример #3
0
 def test_post_unicode(self):
     #
     # Create user
     #
     user = User()
     user.name = 'Test'
     user.username = '******'
     user.email = '*****@*****.**'
     user.set_password('abc123')
     user.is_active = True
     user.save()
     #
     # Create meme
     meme = Meme()
     meme.name = 'MemeName'
     meme.code = 'meme'
     meme.image = None
     meme.owner = user
     meme.save()
     #
     # Create post
     #
     post = Post()
     post.header = 'HeaderText'
     post.footer = 'FooterText'
     post.owner = user
     post.meme = meme
     post.save()
     #
     # Test
     #
     self.assertEqual(unicode(post), 'HeaderText ~ MemeName ~ FooterText')
Пример #4
0
 def test_comment_unicode(self):
     #
     # Create user
     #
     user = User.objects.create_user('user', '*****@*****.**', 'Pwd007',
                                     name='User')
     #
     # Create meme
     #
     meme = Meme()
     meme.code = 'testmeme'
     meme.name = 'Test Meme'
     meme.owner = user
     meme.save()
     #
     # Create post
     #
     post = Post()
     post.header = 'HeaderText'
     post.meme = meme
     post.footer = 'FooterText'
     post.owner = user
     post.save()
     #
     # Create like
     #
     comment = Comment()
     comment.owner = user
     comment.post = post
     comment.body = 'Je te Flus Flis'
     comment.save()
     #
     # Test
     #
     self.assertEqual(unicode(comment), '{} -> {}'.format(unicode(user),
                                                          unicode(post)))