def test_date_datatype(self):
        now = datetime.datetime.now()
        p = db.Post()
        p.post_date = now
        p.save()
        new_p = db.get_latest_post()

        self.assertEqual(new_p.post_date,p.post_date)
    def test_make_post(self):
        p = db.Post()
        p.title = "PostTitle"
        p.caption = "Postcaption"
        p.save()
        new_p = db.get_latest_post()

        self.assertEqual(new_p.title,p.title)
        self.assertEqual(new_p.caption,p.caption)
Пример #3
0
    def test_make_post(self):
        p = db.Post()
        p.title = "PostTitle"
        p.body = "Postbody"
        p.save()
        new_p = db.get_latest_post()

        self.assertEqual(new_p.title,p.title)
        self.assertEqual(new_p.body,p.body)
Пример #4
0
def upload_file():
    encoded = request.form['file']
    decoded = encoded.decode("base64")
    p = db.Post()
    p.title = request.form['title']
    p.caption = "something something"
    p.image_data = decoded
    p.save()
    id_number = db.get_latest_post().post_id
    return url_for("show_image",post_id=id_number)
Пример #5
0
    def test_image_save(self):
        i_file = open("./test-data/black.jpg","rb")
        i_data = i_file.read()
        p = db.Post()
        p.title = "this is the image test"
        p.image_name = os.path.basename(i_file.name)
        p.image_data = i_data
        p.save()

        new_p = db.get_latest_post()
        original = p.image_data
        new = new_p.image_data

        self.assertEquals(original, new)
def show_latest_post():
    post = db.get_latest_post()
    return render_template("view_post.html", post=post)