def handle(self, *args, **options): # # Create superuser # broak = User() broak.name = 'Broak' broak.email = '*****@*****.**' broak.username = '******' broak.is_active = True broak.is_staff = True broak.is_superuser = True broak.set_password('abc123') broak.save() self.user_msg(broak) # # Create memes # meme = Meme() meme.name = 'Bachelor Frog' meme.code = 'bachelor-frog' meme.owner = broak meme.save() self.meme_msg(meme) meme = Meme() meme.name = 'Insanity Wolf' meme.code = 'insanity-wolf' meme.owner = broak meme.save() self.meme_msg(meme) meme = Meme() meme.name = 'Philosoraptor' meme.code = 'Philosoraptor' meme.owner = broak meme.save() self.meme_msg(meme)
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))
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)))
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')
def test_get_resource_path_meme(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() # # Test resource path # path = utils.get_resource_path(meme) self.assertEqual(path, '/memes/{}.{}'.format(meme.pk, settings.API_FORMAT))
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)))
def test_meme_unicode(self): meme = Meme() meme.code = 'bachelor-frog' meme.name = 'Bachelor Frog' self.assertEqual(unicode(meme), meme.name)