Beispiel #1
0
def seed():
    content = """Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""

    for i in range(25):
        post = Post(title="Test Post #{}".format(i), content=content)
        session.add(post)
    session.commit()
Beispiel #2
0
    def setUp(self):
        tag = TagCategory()
        self.post = Post(title='Primeiro post',
                         text='<b>Nose test e fd</b>',
                         tags=tag.string_to_category('python, nose, tdd'))

        self.post.put()
Beispiel #3
0
    def test_apos_salvar_post_put_deve_retornar_a_chave_da_entidade(self):
        tag = TagCategory()
        post = Post(title='Primeiro post',
                    text='<b>Nose test e fd</b>',
                    tags=tag.string_to_category('python, nose, tdd'))

        assert_true(type(post.put().id()).__name__ == 'int')
        post.delete()
Beispiel #4
0
def add():
    form = AddPost()
    if form.validate_on_submit():
        post = Post(current_user.id, form.title.data, form.post.data,
                    form.short_description.data)
        db.session.add(post)
        db.session.commit()
        return redirect(url_for('home'))
    return render_template('posts/add_post.html', form=form, title='Add Post')
Beispiel #5
0
def test_post_mapper_can_retrieve_post(session):
    session.execute(
        "INSERT INTO posts (title, body, created_at, updated_at)"
        "VALUES ('test title', 'test body', '2020-10-26', '2020-10-25')")

    expected = [
        Post("test title", "test body", date(2020, 10, 26), date(2020, 10, 25))
    ]
    assert session.query(Post).all() == expected
Beispiel #6
0
	def setUp(self):
		self.app  = app.test_client()
		tag = TagCategory()
		self.post = Post(title='Primeiro post',
						 text='<b>Nose test e fd</b>',
						 tags=tag.string_to_category('python, nose, tdd'))

		self.post.put() 
		self.mocker = mocker.Mocker()
Beispiel #7
0
def new_post():
    title = request.get_json()['title']
    description = request.get_json()['description']
    error = False
    data = {}
    new_post = Post(title=title, content=description, author=current_user)
    db.session.add(new_post)
    db.session.commit()
    data['description'] = description
    data['title'] = title
    return jsonify(data)
Beispiel #8
0
	def test_delete_post(self):
		self.admin_loggend(5)
		tag = TagCategory()
		post = Post(title='Primeiro post',
					text='<b>Nose test e fd</b>',
					tags=tag.string_to_category('python, nose, tdd'))
		post.put()
		url="%i/delete" % post.key().id()			
		self.app.get(url)
		post = Post.get_by_id( post.key().id() )
		assert_true(post is None)	
Beispiel #9
0
def post():
    form=new_post()
    if form.validate_on_submit():
        id=current_user.id
        print (id)
        post=Post(user_id=id,title=form.title.data,content=form.content.data)
        db.session.add(post)
        db.session.commit()
        flash("{} Article has created".format(form.title.data),'success')
        return  redirect(url_for('home'))
    return render_template("post.html",form=form,title="New Post",legend="New Post")
Beispiel #10
0
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title=form.title.data,
                    subtitle=form.subtitle.data,
                    content=form.content.data,
                    author=current_user)
        db.session.add(post)
        db.session.commit()
        flash('貼文已成功發出', 'success')
        return redirect(url_for('main.home'))
    return render_template('create_post.html',
                           form=form,
                           legend='New Post',
                           title='New Post')