Example #1
0
def delete_post(request, postid):
    """
    Delete the nth post where n = postId entered from the user url
    """
    global cnt_delete
    context = {}

    if Post.exists(postid):
        try:
            fetch = Post.getPostByID(postid)
            if fetch:
                message = 'Post %d Deleted!' %(int(postid))
                fetch.delete()

                request.session['delete'] = True
                cnt_delete = count_session(request, 'delete', cnt_delete)
        except ValueError:
            raise Http404()

        return HttpResponseRedirect('/myblog/')
    else:
        msg = 'Nothing to delete!'
        ss_start = session_start_date(request)
        context = {}
        context.update(csrf(request))
        context = {'message': msg,
                   'sessionStartTime' : ss_start,
                   'sessionStat' : get_sessions(),
                   }

    res = render_to_response('../../Pythonidae/templates/index.html',
                             context,
                             context_instance=RequestContext(request))
    return res
 def setUp(self):
     admin = AdminSite()
     self.ma = PostAdmin(Post, admin)
     for author in User.objects.all():
         title = "%s's title" % author.username
         post = Post(title=title, author=author)
         post.save()
     self.client.login(username='******', password='******')
Example #3
0
 def test_author_names(self):
     names = [("Bob", "Marley", "Bob Marley"), ("Cher", "", "Cher "), ("Sting", "", "Sting "), ("Elliott", "Smith", "Elliott Smith")]
     author = User();
     p1 = Post(author=author)
     for first_name, last_name, expected in names:
         author.first_name = first_name
         author.last_name = last_name
         actual = p1.author_name()
         self.assertEqual(expected, actual)
Example #4
0
 def setUp(self):
     self.now = datetime.datetime.utcnow().replace(tzinfo=utc)
     self.timedelta = datetime.timedelta(15)
     author = User.objects.get(pk=1)
     for count in range(1, 11):
         post = Post(title=f"Post {count} Title", text="foo", author=author)
         if count < 6:
             pubdate = self.now - self.timedelta * count
             post.published_date = pubdate
         post.save()
 def setUp(self):
     self.now = datetime.datetime.utcnow().replace(tzinfo=utc)
     self.timedelta = datetime.timedelta(15)
     author = User.objects.get(pk=1)
     for count in range(1, 11):
         post = Post(title="Post %d Title" % count,
                     text="foo",
                     author=author,
                     published_date=self.now)
         post.save()
Example #6
0
 def setUp(self):
     self.now = datetime.datetime.utcnow().replace(tzinfo=utc)
     self.timedelta = datetime.timedelta(15)
     author = User.objects.get(pk=1)
     for count in range(1, 11):
         post = Post(title='Post %d Title' % count, text='foo', author=author)
         if count < 6:
             #publish the first five posts
             pubdate = self.now - self.timedelta * count
             post.published_date = pubdate
         post.save()
Example #7
0
 def setUp(self):
     self.now = datetime.datetime.utcnow().replace(tzinfo=utc)
     self.timedelta= datetime.timedelta(15)
     author = User.objects.get(pk=1)
     for count in range(1,11):
         post = Post(title="Post %d Title" % count, text="foo", author=author)
         if count < 6:
             # publish the first five posts
             pubdate = self.now - self.timedelta * count
             post.published_date = pubdate
         post.save()
Example #8
0
 def get(self, tag):
   posts = Post.objects(tags=tag)
   tags = Post.objects.distinct("tags")
   all_tags = []
   for tag in tags:
     all_tags.append({
       'tag': tag,
       'count': Post.objects(tags=tag).count()
       })
   print all_tags
   return render_template('posts/list.html', posts = posts, tags = all_tags)
Example #9
0
 def setUp(self):
     self.now = datetime.datetime.utcnow().replace(tzinfo=utc)
     self.timedelta = datetime.timedelta(15)
     author = User.objects.get(pk=1)
     genre1 = Genre(genre="poetry")
     genre1.save()
     for count in range(1, 11):
         post = Post(title="Post %d Title" % count,
                     text="foo",
                     author=author,
                     genre=genre1)
         post.save()
Example #10
0
    def test_author_names(self):
        names = [("Bob", "Marley", "Bob Marley"),
                 ("Name", "Two", "Name Two"),
                 ("Sting", "", "Sting ")]

        author = User()
        p1 = Post(author=author)

        for first_name, last_name, expected in names:
            author.first_name = first_name
            author.last_name = last_name
            actual = p1.author_name()
            self.assertEqual(expected, actual)
Example #11
0
 def setUp(self):
     self.now = datetime.datetime.utcnow().replace(tzinfo=utc)
     self.timedelta = datetime.timedelta(15)
     author = User.objects.get(pk=1)
     for count in range(1, 11):
         title = "Post %d Title" % count
         # print("NEXT TITLE:", title)
         post = Post(title="Post %d Title" % count,
             text="foo",
             author=author)
         if count < 6:
             # print("setting published date") # create 5 records with a published date
             pubdate = self.now - self.timedelta * count
             post.published_date = pubdate 
         post.save()
Example #12
0
    def test_delete_category(self):
        category = Category(name='Tech')
        post = Post(title='test', category=category)
        db.session.add(category)
        db.session.add(post)
        db.session.commit()

        response = self.client.get(url_for('admin.delete_category',
                                           category_id=1),
                                   follow_redirects=True)
        data = response.get_data(as_text=True)
        self.assertNotIn('Category deleted.', data)
        self.assertIn('405 Method Not Allowed', data)

        response = self.client.post(url_for('admin.delete_category',
                                            category_id=1),
                                    follow_redirects=True)
        data = response.get_data(as_text=True)
        self.assertIn('You can not delete the default category.', data)
        self.assertNotIn('Category deleted.', data)
        self.assertIn('Default', data)

        response = self.client.post(url_for('admin.delete_category',
                                            category_id=2),
                                    follow_redirects=True)
        data = response.get_data(as_text=True)
        self.assertIn('Category deleted.', data)
        self.assertIn('Default', data)
        self.assertNotIn('Tech', data)
Example #13
0
    def test_new_category(self):
        response = self.client.get(url_for('admin.new_category'))
        data = response.get_data(as_text=True)
        self.assertIn('New Category', data)

        response = self.client.post(url_for('admin.new_category'),
                                    data=dict(name='Tech'),
                                    follow_redirects=True)
        data = response.get_data(as_text=True)
        self.assertIn('Category created.', data)
        self.assertIn('Tech', data)

        response = self.client.post(url_for('admin.new_category'),
                                    data=dict(name='Tech'),
                                    follow_redirects=True)
        data = response.get_data(as_text=True)
        self.assertIn('Name already in use.', data)

        category = Category.query.get(1)
        post = Post(title='Post Title', category=category)
        db.session.add(post)
        db.session.commit()
        response = self.client.get(url_for('blog.show_category',
                                           category_id=1))
        data = response.get_data(as_text=True)
        self.assertIn('Post Title', data)
Example #14
0
	def test_string_representation(self):
		expected = "This is a title"
		p1 = Post(title=expected)
		actual = str(p1)
		print('Expected: ', expected)
		print('Result: ', actual)
		self.assertEqual(expected, actual)
Example #15
0
def new_post():
    form = PostForm()

    if form.validate_on_submit():
        title = form.title.data
        subtitle = form.subtitle.data
        theme = request.files.getlist('image')[0].filename
        body = form.body.data
        category = Category.query.get(form.category.data)
        topic = Topic.query.get(form.topic.data)
        post = Post(title=title,
                    subtitle=subtitle,
                    theme=theme,
                    body=body,
                    category=category,
                    topic=topic)
        # same with:
        # category_id = form.category.data
        # post = Post(title=title, body=body, category_id=category_id)
        db.session.add(post)
        db.session.commit()

        img_list = request.files.getlist('image')
        img_path = current_app.root_path + '/static/img/' + str(topic.name)
        if img_list[0].filename:

            for f in img_list:
                filename = f.filename
                f.save(os.path.join(img_path, filename))

        flash('Post created.', 'success')
        return redirect(url_for('blog.show_post', post_id=post.id))

    return render_template('admin/new_post.html', form=form)
Example #16
0
def new_post():
    form = UploadForm()
    if form.validate_on_submit():
        file = form.post.data
        content = file.read().decode('utf-8')
        yaml_config = yaml.load(content.split("---")[1].replace('\t', ' '))
        title = yaml_config.get('title')
        body = markdown.markdown(''.join(content.split("---")[2:]),
                                 extensions=['markdown.extensions.extra', 'markdown.extensions.codehilite',
                                             'markdown.extensions.tables', 'markdown.extensions.toc'])

        category_name = yaml_config.get('category')[0]
        category_exist = Category.query.filter_by(name=category_name).first()
        if category_exist:
            category = Category.query.get(category_exist.id)
        else:
            category = Category(name=category_name)
            db.session.add(category)
            db.session.commit()
        post = Post(title=title, body=body, category=category)
        db.session.add(post)
        db.session.commit()
        flash('Post created.', 'success')
        return redirect(url_for('blog.show_post', post_id=post.id))
    return render_template('admin/new_post.html', form=form)
Example #17
0
def create_post():
    """Create new post."""
    if is_admin():
        current_app.logger.info("An admin started creating a new post")
        form = CreatePostForm()
        if form.validate_on_submit():
            post = Post(
                title=form.title.data,
                body=form.body.data,
                private=form.private.data,
                author=current_user,
            )
            current_app.logger.info("New post created")
            db.session.add(post)
            db.session.commit()
            current_app.logger.info(f"Post {post.id} pushed to database")
            current_app.logger.info(
                f"Post {post.id} has been created by user {current_user.id}")
            flash("Post created.")
            return redirect(url_for("index.index"))
        return render_template("blog/create_post.html", form=form, post=None)
    else:
        current_app.logger.warning(
            f"User {current_user.id} attempted creating a post, but was bounced back"
        )
        abort(500)
Example #18
0
def fake_posts(count=50):
    for i in range(count):
        post = Post(title=fake.sentence(),
                    body=fake.text(2000),
                    category=Category.query.get(
                        random.randint(1, Category.query.count())))
        db.session.add(post)
    db.session.commit()
Example #19
0
def fake_posts(count=50):                   # 生成虚拟文章
    for i in range(count):
        post=Post(title=fake.sentence(),
                  body=fake.text(2000),
                  category=Category.query.get(random.randint(1,Category.query.count())),
                  timestamp=fake.date_time_this_year()
                  )
        db.session.add(post)
    db.session.commit()
Example #20
0
 def setUp(self):
     self.now = datetime.datetime.utcnow().replace(tzinfo=utc)
     self.timedelta = datetime.timedelta(15)
     author = User.objects.get(pk=1)
     self.category = Category(name='A Category')
     self.category.save()
     for count in range(1,11):
         post = Post(title="Post %d Title" % count,
                     text="foo",
                     author=author)
         if count < 6:
             # publish the first five posts
             pubdate = self.now - self.timedelta * count
             post.published_date = pubdate
         post.save()
         if bool(count & 1):
             # put odd items in category:
             self.category.posts.add(post)
Example #21
0
    def setUp(self):
        super(AdminTestCase, self).setUp()
        self.login()

        category = Category(name='Default')
        post = Post(title='Hello', category=category, body='Blah...')
        comment = Comment(body='A comment', post=post, from_admin=True)
        link = Link(name='GitHub', url='https://github.com/greyli')
        db.session.add_all([category, post, comment, link])
        db.session.commit()
Example #22
0
def edit_post(request, postid):
    """
    Fetch the nth post from the blog, validate the input data and update the model,
    """
    global cnt_edit

    queryset = Post.getPostByID(postid)
    ss_start = session_start_date(request)

    if queryset:
        queryset = Post.getPostByID(postid)
        context = {'post': queryset,
                   'sessionStartTime' : ss_start,
                   'sessionStat' : get_sessions(),
                   }
    else:
        queryset = Post.objects.get(id=postid)

    if request.method == 'POST' and request.POST.get('update'):
        # Create a form to edit an existing Post, but use
        # POST data to populate the form!
        p_instance = Post.objects.get(pk=postid)
        update_form = PostForm(request.POST, instance=p_instance)
        if update_form.is_valid():
            update_form.save()

            request.session["edit"] = True
            cnt_edit = count_session(request, 'edit', cnt_edit)
            ss_start = session_start_date(request)

            message = "Post %d: updated! " %(int(postid))
            context = {'post': queryset, 'message': message}
            return HttpResponseRedirect('/myblog/'+ postid)
    elif request.method == 'POST' and request.POST.get('cancel'):
        message = "Updating post cancelled!"
        return HttpResponseRedirect('/myblog/')
    else:
        message = "Updating post interrupted!"

    res = render_to_response('editblog.html',
                              context,
                              context_instance=RequestContext(request))
    return res
Example #23
0
    def setUp(self) -> None:
        super().setUp()
        self.login()

        category = Category(name="Default")
        post = Post(title="Hello", category=category, body="Blah...")
        comment = Comment(body="A comment", post=post, from_admin=True)
        link = Link(name="GitHub", url="https://github.com/greyli")
        db.session.add_all([category, post, comment, link])
        db.session.commit()
Example #24
0
 def get(self):
   user = User.objects.get(id=current_user.id)
   form = ProfileForm(obj=user)
   posts = Post.objects(author=current_user.id)
   return render_template('users/profile.html', 
       form=form,
       posts = posts,
       user = user,
       twitter_conn=social.twitter.get_connection(),
       facebook_conn=social.facebook.get_connection())
Example #25
0
def create_post():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data.capitalize(),
                    body=form.body.data,
                    user_id=current_user.id,
                    tags=gettags(form.tags.data))
        db.session.add(post)
        db.session.commit()
        return redirect(url_for('posts.index'))
    return render_template('post/create-post.html', form=form)
Example #26
0
def fake_posts(count=50):
    for i in range(count):
        post = Post(
            title=fake.word(),
            body=fake.text(),
            timestamp=fake.date_time_this_year(),
            category=Category.query.get(random.randint(1, Category.query.count())),
            can_comment=random.randint(0, 1) > 0,
        )
        db.session.add(post)
    db.session.commit()
Example #27
0
def fake_posts(count=50):
    """生成虚拟文章"""
    for i in range(count):
        post = Post(
            title=fake.sentence(),
            body=fake.text(2000),
            timestamp=fake.date_time_this_year(),
            # 每一篇文章指定一个随机分类,主键值为1到所有分类数量之间的随机值
            category=Category.query.get(
                random.randint(1, Category.query.count())))
        db.session.add(post)
    db.session.commit()
Example #28
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        title = form.title.data
        body = form.body.data
        category = Category.query.get(form.category.data)
        post = Post(title=title, body=body, category=category)
        db.session.add(post)
        db.session.commit()
        flash("post created", "success")
        return redirect(url_for("blog.show_post", post_id=post.id))
    return render_template("admin/new_post.html", form=form)
Example #29
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        title = form.title.data
        category = Category.query.get(form.category.data)
        body = form.body.data
        post = Post(title=title, category=category, body=body)
        db.session.add(post)
        db.session.commit()
        flash('文章已创建', 'success')
        return redirect(url_for('blog.show_post', post_id=post.id))
    return render_template('admin/new_post.html', form=form)
Example #30
0
def create_post(request):
	user = request.user
	blog_id = request.POST.get('blog_id')
	blog = Blog.objects.get(pk = blog_id)
	post_id = request.POST.get('post_id')
	if user not in blog.authors.all():
		return HttpResponse("Sorry you are not authorized to post here")
	else:
		if post_id:
			post = Post.objects.get(pk=post_id)
			if user != post.author:
				return HttpResponse("Sorry you are not authorized to edit here")
		else:
			post = Post()
		post.author = user
		post.blog = blog
		post.title = request.POST.get('title')
		post.body = request.POST.get('body')
		
		tags = request.POST.get('tags')
		tag_names = tags.split(',')
		if not tags.strip():
			tag_names = [constant.NO_TAG]
		tag_set = set(tag_names)
		tag_list = []
		for tname in tag_set:
			tname_s = tname.strip()
			try:
				tag = Tag.objects.get(name__iexact=tname_s)
			except Tag.DoesNotExist:
				tag = None
			if not tag:
				tag = Tag()
				tag.name = tname_s
				tag.save()
			tag_list.append(tag)
		post.save()
		post.tags = tag_list;
		post.save()
		return HttpResponseRedirect(reverse('myblog:index'))
Example #31
0
def create_post():
    """Create new post."""
    form = CreatePostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data,
                    body=form.body.data,
                    private=form.private.data,
                    author=current_user)
        db.session.add(post)
        db.session.commit()
        flash('Post created.')
        return redirect(url_for('index.index'))
    return render_template('blog/create_post.html', form=form, post=None)
Example #32
0
def fake_posts(count=50):
    tags_count = Tag.query.count()

    for i in range(count):
        tags_indexs = random.sample(range(1, tags_count+1), 2)
        post = Post(
            title=fake.sentence(),
            body=fake.text(2000),
            category=Category.query.get(random.randint(1, Category.query.count())),
            tags=[Tag.query.get(tags_indexs[0]),Tag.query.get(tags_indexs[1])],
            timestamp=fake.date_time_this_decade()
        )
        db.session.add(post)
    db.session.commit()
Example #33
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        title = form.title.data
        body = form.body.data
        private = form.private.data
        # category = Category.query.get(form.category.data)
        categories = [Category.query.get(i) for i in form.categories.data]
        post = Post(title=title, body=body, private=private, categories=categories)
        db.session.add(post)
        db.session.commit()
        flash("Post created.", "success")
        return redirect(url_for("blog.show_post", post_id=post.id))
    return render_template("admin/new_post.html", form=form)
Example #34
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data,
                    content=form.content.data,
                    author=current_user)
        db.session.add(post)
        db.session.commit()
        flash('Your post has been created!', 'success')
        return redirect(url_for('main.home'))
    return render_template('create_post.html',
                           title='New Post',
                           form=form,
                           legend='New Post')
Example #35
0
def create():
    form = CreateForm()
    if form.validate_on_submit():
        title = form.title.data
        body = form.body.data

        post = Post(title=title,
                    body=body,
                    author_id=g.user.id,
                    timestamp=time.strftime("%Y-%m-%d %H:%M:%S",
                                            time.localtime()))
        db.session.add(post)
        db.session.commit()
        return redirect(url_for('blog.index'))
    return render_template('create.html', form=form)
Example #36
0
def delete_post(request, postid):
    """
    Delete the nth post where n = postId entered from the user url
    """
    context = {}
    if Post.exists(postid):
        queryset = Post.getPostByID(postid)
        if queryset:
            if queryset.author == request.user:
                message = 'Post %d Deleted!' %(int(postid))
                queryset.delete()
                return HttpResponseRedirect('/myblog/')
            else:
                return render_to_response('index.html',
                              {'message':  "You can only delete your blog posts."},
                              context_instance=RequestContext(request))
    else:
        context = {}
        context.update(csrf(request))
        context = {'message': "Nothing to delete!"}

    return render_to_response('index.html',
                             context,
                             context_instance=RequestContext(request))
Example #37
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        title = form.title.data
        body = form.body.data
        category = Category.query.get(form.category.data)
        post = Post(title=title, body=body, category=category, read=1)
        # same with:
        # category_id = form.category.data
        # post = Post(title=title, body=body, category_id=category_id)
        db.session.add(post)
        db.session.commit()
        flash('Post created.', 'success')
        return redirect(url_for('blog.show_post', post_id=post.id))
    return render_template('admin/new_post.html', form=form)
Example #38
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        #save it into database
        post = Post(title=form.title.data,
                    content=form.content.data,
                    author=current_user)
        db.session.add(post)
        db.session.commit()
        #end
        flash('your post has been creatd', 'success')
        return redirect(url_for('home'))
    return render_template('create_post.html',
                           title='Post',
                           form=form,
                           legend='Post')
Example #39
0
def fake_posts(count=50):
    for i in range(count):
        post = Post(
            title=fake.sentence(),
            body=fake.text(2000),
            # category=Category.query.get(random.randint(1, Category.query.count())),
            timestamp=fake.date_time_this_year(),
        )
        post.categories.extend(
            set(
                random.choices(
                    Category.query.all(),
                    k=random.randint(1,
                                     Category.query.count() // 3),
                )))
        db.session.add(post)
    db.session.commit()
Example #40
0
    def setUp(self):
        super(BlogTestCase, self).setUp()
        self.login()

        category = Category(name='Default')
        topic = Topic(name="test")
        post = Post(title='Hello Post',
                    category=category,
                    topic=topic,
                    body='Blah...')
        comment = Comment(body='A comment',
                          post=post,
                          from_admin=True,
                          reviewed=True)
        link = Link(name='GitHub', url='https://github.com/syntomic')

        db.session.add_all([category, post, comment, link])
        db.session.commit()
Example #41
0
def add_post():
    title = request.json.get('title')
    body = request.json.get('body')
    html = request.json.get('html')
    timestamp = datetime.fromtimestamp(request.json.get('timestamp') / 1000)
    category_id = request.json.get('category_id')
    post = Post(title=title,
                body=body,
                timestamp=timestamp,
                category_id=category_id,
                html=html)
    db.session.add(post)
    db.session.commit()
    return jsonify(title=title,
                   body=body,
                   post_id=post.id,
                   category_id=category_id,
                   timestamp=timestamp,
                   html=html)
Example #42
0
def show_post(request):
    """
    Create a view for showing the latest 6 post from the blog
    data is fetched from the model using fetchAllPosts() method
    """
    queryset = Post.fetchAllPosts()
    if queryset:
        msg = "All blog posts"
        context = {'posts': queryset,
                   'message': msg,
                   }

        # Create HTTP response , pass data from one view to another
    else:
        msg = "Empty blog...add new posts!"
        context = {'posts': '', 'message': msg}

    return render_to_response('index.html',
                              context,
                              context_instance=RequestContext(request))
Example #43
0
  def post(self):
    '''
    Create new post
    '''
    post_id = None
    if 'id' in request.json:
      post_id = request.json['id']

    title = request.json['title']
    body = request.json['body']
    tags = request.json['tags']
    tags = [slugify(item) for item in tags]

    if (not title) or (not body):
      return jsonify({
        'error': 'title & body is required.',
        'data': {'title': title,
          'body': body,
          'slug': slugify(title)
           }
        })
    if post_id:
      post = Post.objects.get(id=post_id)
    else:
      post = Post(author=current_user.id)

    post.title = title
    post.body = body
    post.slug = slugify(title)
    post.tags = tags
    post.save()
    return jsonify({
        'success': 'success',
        'post' : post,
        'edit_url': post.get_edit_url()
        })
Example #44
0
def detail_post(request, postid):
    """
    Display details of the nth post where n = postId from the user url
    """
    global cnt_visit

    request.session['detail'] = True
    cnt_visit = count_session(request, 'detail', cnt_visit)
    ss_start = session_start_date(request)

    fetch = Post.getPostByID(postid)
    if fetch:
       msg = "Detail view post %d: " % (int(postid))
       context = {'post': fetch,
                  'message': msg,
                  'sessionStartTime' : ss_start,
                  'sessionStat' : get_sessions(),
                  }
       res = render_to_response('singlepost.html',
                                context,
                                context_instance=RequestContext(request))
       return res
    return HttpResponseRedirect('/myblog/')
Example #45
0
def show_post(request):
    """
    Create a view for showing the latest 6 post from the blog
    data is fetched from the model using fetchAllPosts() method
    """
    queryset = Post.fetchAllPosts()
    ss_start = session_start_date(request)
    if queryset:
        msg = "All blog posts"
        context = {'posts': queryset,
                   'message': msg,
                   'sessionStartTime' : ss_start,
                   'sessionStat' : get_sessions(),
                   }

        # Create HTTP response , pass data from one view to another
    else:
        msg = "Empty blog...add new posts!"
        context = {'posts': '', 'message': msg}

    res = render_to_response('../../Pythonidae/templates/index.html',
                              context,
                              context_instance=RequestContext(request))
    return res
Example #46
0
 def get(self):
   posts = Post.objects(author=current_user.id)
   return render_template('users/personal.html', posts=posts)
Example #47
0
 def get(self, username):
   user = User.objects.get_or_404(username=username)
   posts = Post.objects(author=user.id)
   return render_template('users/user.html', user=user, posts=posts)
Example #48
0
 def test_author_name(self):
     expected = u"Mr. Administrator"
     p1 = Post(author=self.user)
     actual = p1.author_name()
     self.assertEqual(expected, actual)