Style fixes.

This commit is contained in:
Imran Sobir 2017-02-09 15:44:51 +05:00
parent 828b0c00b5
commit 4eccfd5396

View File

@ -17,20 +17,23 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. # along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
import datetime
import tempfile
from PyQt5.QtCore import QUrl from PyQt5.QtCore import QUrl
import pytest
from qutebrowser.browser import history, qutescheme from qutebrowser.browser import history, qutescheme
from qutebrowser.utils import objreg from qutebrowser.utils import objreg
import datetime
import pytest
import tempfile
class TestHistoryHandler: class TestHistoryHandler:
"""Test the qute://history endpoint.""" """Test the qute://history endpoint."""
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def fake_objects(self, fake_save_manager): def fake_objects(self, fake_save_manager):
""" Create fake web-history with history for three different days """ """Create fake web-history with history for three different days."""
try: try:
original_save_manager = objreg.get('save-manager') original_save_manager = objreg.get('save-manager')
except KeyError: except KeyError:
@ -78,14 +81,14 @@ class TestHistoryHandler:
objreg.delete('web-history') objreg.delete('web-history')
def test_history_without_query(self): def test_history_without_query(self):
""" Test qute://history shows today's history when it has no query """ """Ensure qute://history shows today's history when it has no query."""
_mimetype, data = qutescheme.qute_history(QUrl("qute://history")) _mimetype, data = qutescheme.qute_history(QUrl("qute://history"))
key = "<span class=\"date\">{}</span>".format( key = "<span class=\"date\">{}</span>".format(
datetime.date.today().strftime("%a, %d %B %Y")) datetime.date.today().strftime("%a, %d %B %Y"))
assert key in data assert key in data
def test_history_with_bad_query(self): def test_history_with_bad_query(self):
""" Test qute://history shows today's history when given bad query """ """Ensure qute://history shows today's history when given bad query."""
url = QUrl("qute://history?date=204-blaah") url = QUrl("qute://history?date=204-blaah")
_mimetype, data = qutescheme.qute_history(url) _mimetype, data = qutescheme.qute_history(url)
key = "<span class=\"date\">{}</span>".format( key = "<span class=\"date\">{}</span>".format(
@ -93,7 +96,7 @@ class TestHistoryHandler:
assert key in data assert key in data
def test_history_today(self): def test_history_today(self):
""" Test qute://history shows history for today """ """Ensure qute://history shows history for today."""
url = QUrl("qute://history") url = QUrl("qute://history")
_mimetype, data = qutescheme.qute_history(url) _mimetype, data = qutescheme.qute_history(url)
assert "today" in data assert "today" in data
@ -101,7 +104,7 @@ class TestHistoryHandler:
assert "yesterday" not in data assert "yesterday" not in data
def test_history_yesterday(self): def test_history_yesterday(self):
""" Test qute://history shows history for yesterday """ """Ensure qute://history shows history for yesterday."""
url = QUrl("qute://history?date=" + self.prev_date.strftime("%Y-%m-%d")) url = QUrl("qute://history?date=" + self.prev_date.strftime("%Y-%m-%d"))
_mimetype, data = qutescheme.qute_history(url) _mimetype, data = qutescheme.qute_history(url)
assert "today" not in data assert "today" not in data
@ -109,7 +112,7 @@ class TestHistoryHandler:
assert "yesterday" in data assert "yesterday" in data
def test_history_tomorrow(self): def test_history_tomorrow(self):
""" Test qute://history shows history for tomorrow """ """Ensure qute://history shows history for tomorrow."""
url = QUrl("qute://history?date=" + self.next_date.strftime("%Y-%m-%d")) url = QUrl("qute://history?date=" + self.next_date.strftime("%Y-%m-%d"))
_mimetype, data = qutescheme.qute_history(url) _mimetype, data = qutescheme.qute_history(url)
assert "today" not in data assert "today" not in data