Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/tests/views/test_main.py
# Copyright (C) 2016 The Software Heritage developers | # Copyright (C) 2016 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from nose.tools import istest | from nose.tools import istest | ||||
from unittest.mock import patch | |||||
from .. import test_app | from .. import test_app | ||||
class MainViewTestCase(test_app.SWHViewTestCase): | class MainViewTestCase(test_app.SWHViewTestCase): | ||||
render_template = False | render_template = False | ||||
@patch('flask.flash') | |||||
@istest | @istest | ||||
def homepage(self, mock_flash): | def homepage(self): | ||||
# given | |||||
mock_flash.return_value = 'something' | |||||
# when | # when | ||||
rv = self.client.get('/') | rv = self.client.get('/') | ||||
# then | # then | ||||
self.assertEquals(rv.status_code, 200) | self.assertEquals(rv.status_code, 302) | ||||
self.assert_template_used('home.html') | self.assertRedirects(rv, '/browse/') | ||||
mock_flash.assert_called_once_with( | |||||
'This Web app is still work in progress, use at your own risk', | |||||
'warning') | |||||
@istest | @istest | ||||
def info(self): | def info(self): | ||||
# when | # when | ||||
rv = self.client.get('/about/') | rv = self.client.get('/about/') | ||||
self.assertEquals(rv.status_code, 200) | self.assertEquals(rv.status_code, 200) | ||||
self.assert_template_used('about.html') | self.assert_template_used('about.html') | ||||
self.assertIn(b'About', rv.data) | self.assertIn(b'About', rv.data) |