Skip to content

Instantly share code, notes, and snippets.

@dennismonsewicz
Created June 18, 2014 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennismonsewicz/5e02481f8b91df62f015 to your computer and use it in GitHub Desktop.
Save dennismonsewicz/5e02481f8b91df62f015 to your computer and use it in GitHub Desktop.
class TestInitViews(TestCase):
render_templates = False
def create_app(self):
app = Flask(__name__)
app.config['TESTING'] = True
app.config['SECRET_KEY'] = 'sekrit!'
app.register_blueprint(blueprint)
return app
def setUp(self):
self.app = app.test_client()
self.cookie = '{ "account_id": 100 }'
@patch("api.helpers.session_helpers.signing")
@patch("api.client.request")
def test_root_route_template_rendered(self, request_mock, signing_mock):
request_mock.cookies.get.return_value = self.cookie
signing_mock.get_cookie_signer.return_value.unsign.return_value = self.cookie
with self.app as c:
with c.session_transaction() as sess:
sess['accountId'] = 100
resp = c.get('/')
self.assert_template_used('index.html')
def test_root_route_404(self):
res = self.client.get('/foo')
self.assertEqual(res.status_code, 404)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment