def test_timestamp_fmt(fmt, expected, model_validator, config_stub,
                       data_tmpdir):
    """Validate the filtering and sorting results of set_pattern."""
    config_stub.val.completion.timestamp_format = fmt
    db = sql.Database(str(data_tmpdir / 'test_timestamp_fmt.db'))
    hist = sql.SqlTable(db, '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(database=hist.database)
    model_validator.set_model(cat)
    cat.set_pattern('')
    model_validator.validate([('foo', '', expected)])
Exemplo n.º 2
0
def init(db_path: pathlib.Path, parent: Optional[QObject] = None) -> None:
    """Initialize the web history.

    Args:
        db_path: The path for the SQLite database.
        parent: The parent to use for WebHistory.
    """
    global web_history
    progress = HistoryProgress()
    database = sql.Database(str(db_path))
    web_history = WebHistory(database=database, progress=progress, parent=parent)

    if objects.backend == usertypes.Backend.QtWebKit:  # pragma: no cover
        from qutebrowser.browser.webkit import webkithistory
        webkithistory.init(web_history)
        return
    assert objects.backend == usertypes.Backend.QtWebEngine, objects.backend
def hist(data_tmpdir, config_stub):
    db = sql.Database(str(data_tmpdir / 'test_histcategory.db'))
    config_stub.val.completion.timestamp_format = '%Y-%m-%d'
    config_stub.val.completion.web_history.max_items = -1
    return sql.SqlTable(db, 'CompletionHistory',
                        ['url', 'title', 'last_atime'])
Exemplo n.º 4
0
def database(data_tmpdir):
    """Create a Database object."""
    db = sql.Database(str(data_tmpdir / 'test.db'))
    yield db
    db.close()