-
-
Save dennismonsewicz/5e02481f8b91df62f015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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