Skip to content

Instantly share code, notes, and snippets.

View mattste's full-sized avatar

Matt Stewart-Ronnisch mattste

View GitHub Profile
@mattste
mattste / actions.js
Created November 4, 2016 04:39
Jest Mock Help
// Is there a way for me to mock the fetchNotifications call?
export function fetchNotifications() {
return dispatch => {
dispatch(fetchNotificationsRequest())
return get('/notifications/self')
.then(json => dispatch(fetchNotificationsSuccess(json)))
.catch(err => dispatch(fetchNotificationsFailure(err)))
}
}
import { get, post, put } from '../../utils/APIUtils'
export function fetchNotifications() {
return dispatch => {
dispatch(fetchNotificationsRequest())
// need to mock this get call
return get('/notifications/self')
.then(json => dispatch(fetchNotificationsSuccess(json.body)))
from flask import Flask
from flask.ext.bootstrap import Bootstrap
from flask.ext.mail import Mail
from flask.ext.moment import Moment
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from config import config
bootstrap = Bootstrap()
mail = Mail()
@mattste
mattste / console.sh
Last active August 29, 2015 14:03
follow_redirects not working
response.data:
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n<title>Redirecting...</title>\n<
h1>Redirecting...</h1>\n<p>You should be redirected automatically to target URL: <a href="/auth/login">/auth/login</a>. If
not click the link.'
ERROR OCCURS ON LINE 19 OF TEST.PY
@mattste
mattste / error.py
Created July 3, 2014 18:09
Flask testcase failing on line 17 of gist
Error:
/tests/test_register_login.py(41)test_register_and_login()
-> self.assertTrue(response.status_code == 302)
> /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(424)assertTrue()
-> raise self.failureException(msg)
Test:
def test_register_and_login(self):
# register new account
response = self.client.post(url_for('auth.register'), data={
@mattste
mattste / views.py
Created June 27, 2014 00:44
Edit post
def edit(id):
post = Post.query.get_or_404(id)
form = PostForm()
if form.validate_on_submit():
post.body = form.body.data
db.session.add(post)
flash('The post has been updated.')
return redirect(url_for('.post', id=post.id))
form.body.data = post.body
return render_template('edit_post.html', form=form)