parent
7fd0b52360
commit
2965f954ba
@ -80,7 +80,7 @@ class HistoryCategory(QSqlQueryModel):
|
|||||||
for i in range(len(words)))
|
for i in range(len(words)))
|
||||||
|
|
||||||
# replace ' in timestamp-format to avoid breaking the query
|
# replace ' in timestamp-format to avoid breaking the query
|
||||||
timestamp_format = config.val.completion.timestamp_format
|
timestamp_format = config.val.completion.timestamp_format or ''
|
||||||
timefmt = ("strftime('{}', last_atime, 'unixepoch', 'localtime')"
|
timefmt = ("strftime('{}', last_atime, 'unixepoch', 'localtime')"
|
||||||
.format(timestamp_format.replace("'", "`")))
|
.format(timestamp_format.replace("'", "`")))
|
||||||
|
|
||||||
|
@ -205,3 +205,20 @@ def test_remove_rows_fetch(hist):
|
|||||||
hist.delete('url', '298')
|
hist.delete('url', '298')
|
||||||
cat.removeRows(297, 1)
|
cat.removeRows(297, 1)
|
||||||
assert cat.rowCount() == 299
|
assert cat.rowCount() == 299
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('fmt, expected', [
|
||||||
|
('%Y-%m-%d', '2018-02-27'),
|
||||||
|
('%m/%d/%Y %H:%M', '02/27/2018 08:30'),
|
||||||
|
('', ''),
|
||||||
|
])
|
||||||
|
def test_timestamp_fmt(fmt, expected, model_validator, config_stub, init_sql):
|
||||||
|
"""Validate the filtering and sorting results of set_pattern."""
|
||||||
|
config_stub.val.completion.timestamp_format = fmt
|
||||||
|
hist = sql.SqlTable('CompletionHistory', ['url', 'title', 'last_atime'])
|
||||||
|
atime = datetime.datetime(2018, 2, 27, 8, 30)
|
||||||
|
hist.insert({'url': 'foo', 'title': '', 'last_atime': atime.timestamp()})
|
||||||
|
cat = histcategory.HistoryCategory()
|
||||||
|
model_validator.set_model(cat)
|
||||||
|
cat.set_pattern('')
|
||||||
|
model_validator.validate([('foo', '', expected)])
|
||||||
|
Loading…
Reference in New Issue
Block a user