Ejemplo n.º 1
0
 def test_invalid_basic_image_upload(self):
     """Given an INVALID img url, will
     we get failure message"""
     img_url = "http://blsjdfkj.com/aslkda.png"
     imgur_usr = None
     response = im_control.image_upload(imgur_usr, img_url)
     assert response['success'] == False
Ejemplo n.º 2
0
def upload_and_post():
    if (request.method == 'POST' and
            r_h.establish_oauth(reddit, current_user.reddit_user)):
        # TODO: Sanitize inputs
        print(request.form)
        imgur_response = im_control.image_upload(db, 
                request.form['img_url'], current_user.imgur_user)
        print(imgur_response)
        if ('success' in imgur_response and 
                imgur_response['success'] == True):
            # Image Uploaded
            # Optional comments
            cur_comment = ""
            if ('comment' in request.form):
                cur_comment = request.form['comment']

            args = {'url': imgur_response['imgur_url'],
                    'title': request.form['title'],
                    'subreddit': request.form['subreddit'],
                    'comment': cur_comment}
            link = r_h.submit_post_and_comment(reddit, 
                    current_user.reddit_user,
                    args)
            flash(link, "success")
        elif ('success' not in imgur_response): 
            """Internal coding error or structural
            change in imgur_backend handling"""
            return 'Unhandled server error'
        elif (imgur_response['success'] == False):
            flash(imgur_response['error'], 'danger')
    return redirect(url_for("home")) # Always redirect back to home
Ejemplo n.º 3
0
 def test_valid_basic_image_upload(self):
     """Given a VALID img url, can we
     do a basic upload of the image?"""
     img_url = "http://placehold.it/120x120&text=image1"
     imgur_usr = None
     response = im_control.image_upload(imgur_usr, img_url)
     assert response['success'] == True