Commit Graph

124 Commits

Author SHA1 Message Date
siddhugolu
4862b2faf9 modified pylint pragmas 2017-10-22 23:52:35 +05:30
Michael Hoang
249e497d36 Add test for window completion 2017-10-11 17:18:13 +11:00
Florian Bruhin
2a4f10f0f5 Add qapp for tabbed_browser_stubs 2017-09-20 11:30:18 +02:00
Florian Bruhin
3a5241b642 Start using attrs
Closes #1073
2017-09-19 22:21:45 +02:00
Florian Bruhin
5298d14084 Move backend initialization to config.py 2017-09-18 23:01:17 +02:00
Florian Bruhin
852baaa8c3 Drop support for Qt < 5.7.1
See #2742
2017-09-18 23:01:17 +02:00
Florian Bruhin
2e8419db27 Fix lint 2017-09-15 17:24:39 +02:00
Florian Bruhin
3d3391b55e Clean up *_tmpdir fixtures 2017-09-15 14:32:03 +02:00
Florian Bruhin
fa4ea912c9 Get rid of init_standarddir fixture
Instead, always patch in tmpdir's so we don't write to qute_test folders.
2017-09-15 14:30:46 +02:00
Florian Bruhin
54dfc083f9 Remove default_config fixture 2017-09-15 14:13:27 +02:00
Florian Bruhin
c5c566aadc tests: Bump up timeout for CallbackChecker 2017-09-15 12:07:54 +02:00
Florian Bruhin
ad2598b475 Add initial support for standarddir.config(auto=True)
This doesn't actually migrate things yet.
See #2791, #383.
2017-09-13 17:26:56 +02:00
Florian Bruhin
40ee89bddc Initialize monospace fonts in tests properly
See #2825
2017-09-12 22:12:37 +02:00
Ryan Roden-Corrent
71b71dbc58 Merge remote-tracking branch 'upstream/master' into HEAD 2017-08-06 18:13:49 -04:00
Ryan Roden-Corrent
ea459a1eca SQL code review fixes.
- Ignore invalid variable name in flake8 (pylint already checks this and
  we don't want to have to double-ignore)
- Fix and test completion bug with `:set asdf `
- Remove unused import
- Use `assert not func.called` instead of `func.assert_not_called` for
  backwards compatibility
2017-07-12 08:19:31 -04:00
Ryan Roden-Corrent
cf4ac1a5b7 SQL code review changes.
- use mocker.Mock instead of mock.Mock to avoid an extra import
- attach model to validator sooner so it can validate changes in the
  model during the test
2017-07-08 16:34:38 -04:00
Ryan Roden-Corrent
f9f8900fe9 More sql code review fixes.
- remove outdated comment
- fix sql init error message
- clean up history text import code
- fix test_history file path in coverage check
- use real web history, not stub, for completion model tests
- use qtmodeltester in sql/list_category tests
- test url encoding in history tests
- fix test_clear by using a callable mock
- remove test_debug_dump_history_oserror as the check is now the same as
  for the file not existing
- rename nonempty to data in test_completionmodel
- add more delete_cur_item tests
- test empty option/value completion
2017-07-08 09:57:32 -04:00
Florian Bruhin
8933b4c5da Avoid calling configdata.init() in tests
It takes unnecessary time (20ms without C extensions) to initialize it over and
over again - and for some reason, it takes 20s (!) on Travis.
2017-07-04 15:08:04 +02:00
Florian Bruhin
9dfe4429d7 Import qutebrowser.app in conftest 2017-07-04 15:08:04 +02:00
Florian Bruhin
d5cd0b19b0 Update test_basekeyparser for new config 2017-07-04 15:08:04 +02:00
Florian Bruhin
22b0f2fd24 Various simple test updates for new config
test_cache
test_cookies
test_webkitelem
test_cmdutils
test_runners
test_completionwidget
test_messageview
test_editor
test_miscwidgets
test_sessions
test_urlutils
test_utils
test_prompt
statusbar/test_*
test_cmdhistory
test_tabwidget
test_tab
test_downloads
test_networkmanager
2017-07-04 15:08:04 +02:00
Florian Bruhin
2c3981e57e Get rid of Config.read_configdata()
No need for this indirection
2017-07-04 15:08:03 +02:00
Florian Bruhin
3edebce833 Add tests for :set 2017-07-04 15:08:03 +02:00
Florian Bruhin
725ffef5f3 Use a real config object in unit tests 2017-07-04 15:08:03 +02:00
Florian Bruhin
a5c8a52dd5 Update config_stub for tests 2017-07-04 15:08:03 +02:00
Ryan Roden-Corrent
46161c3af0 Refactor delete_cur_item.
Taking the completion widget as an argument was overly complex.
The process now looks like:

1. CompletionView gets deletion request
2. CompletionView passes selected index to CompletionModel
3. CompletionModel passes the row data to the owning category
4. The category runs its custom completion function.

This also fixes a bug. With the switch to the hybrid (list/sql)
completion model, the view was no longer updating when items were
deleted. This fixes that by ensuring the correct signals are emitted.

The SQL model must be refreshed by running the query. We could try using
a SqlTableModel so we can call removeRows instead.

The test for deleting a url fails because qmodeltester claims the length
of the query model is still 3.
2017-06-26 08:57:36 -04:00
Ryan Roden-Corrent
71191f10a2 Only complete most recent atime for url.
The history completion query is extended to pick only the most recent item for
a given url.

The tests in test_models now check for ordering of elements.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
de5be0dc5a Store history in an on-disk sqlite database.
Instead of reading sqlite history from a file and storing it in an in-memory
database, just directly use an on-disk database. This resolves #755, where
history entries don't pop in to the completion menu immediately as they are
still being read asynchronously for a few seconds after the browser starts.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
f95dff4d9e Decouple categories from completionmodel.
Instead of add_list and add_sqltable, the completion model now supports
add_category, and callees either pass in a SqlCategory or ListCategory. This
makes unit testing much easier.

This also folds CompletionFilterModel into the ListCategory class.
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
56f3b3a027 Small review fixups for SQL implementation.
Respond to the low-hanging code review fruit:

- Clean up some comments
- Remove an acidentally added duplicate init_autosave
- Combine two test_history tests
- Move test_init cleanup into a fixture to ensure it gets called.
- Name the _ argument of bind(_) to _key
- Ensure index is valid for first_item/last_item
- Move SqlException to top of module
- Rename test_index to test_getitem
- Return QItemFlags.None instead of None
- Fix copyright dates (its 2017 now!)
- Use * to force some args to be keyword-only
- Make some returns explicit
- Add sql to LOGGER_NAMES
- Add a comment to explain the sql escape statement
2017-06-19 07:44:11 -04:00
Ryan Roden-Corrent
a774647c26 Get test_models mostly working again.
- Adjust _check_completions to work for CompletionModel and SqlCompletionModel
- Move sql initialization into a reusable fixture
- Remove the bookmark/quickmark/history stubs, as they're now handled by sql
- Disable quickmark/bookmark model tests until their completion is ported to
  sql.
- Disable urlmodel tests for features that have to be implemented in SQL:
    - LIMIT (for history-max-items)
    - Configurable column order (for quickmarks)
    - Configurable formatting (for timestamp-format
2017-06-19 07:42:12 -04:00
Florian Bruhin
822623f2ed Finally update copyrights... 2017-05-09 21:37:03 +02:00
Florian Bruhin
ca4f249c30 Use three-argument form of monkeypatch.*attr 2017-03-01 11:33:41 +01:00
Florian Bruhin
b1a95a3930 Add automatic backend selection in earlyinit 2017-02-05 17:09:04 +01:00
Florian Bruhin
d64efa6b9b Fix test_tabwidget 2016-11-15 23:40:24 +01:00
Florian Bruhin
ece3f3a2e1 Update to pytest-qt 2.1.0 2016-10-26 07:42:41 +02:00
Florian Bruhin
54c32cc74e Fix long line 2016-09-12 20:41:51 +02:00
Florian Bruhin
e6680c3c60 Also redirect $HOME for QtWebEngine tests
See https://github.com/The-Compiler/qutebrowser/pull/1637#issuecomment-243043811
2016-09-12 19:55:31 +02:00
Florian Bruhin
2df971a79c Move short_tmpdir fixture to conftest.py 2016-09-09 18:46:51 +02:00
Florian Bruhin
1e0f97b64d pylint: Disable invalid-name in helpers/fixtures 2016-09-05 21:32:45 +02:00
Florian Bruhin
7592345b6e Make unittests work without QtWebKit 2016-09-05 18:45:50 +02:00
Florian Bruhin
df3733af54 tests: Use pytest.fixture instead of yield_fixture
See #1877
2016-08-22 07:40:24 +02:00
Florian Bruhin
7dadc28eb7 Handle an immediate callback in CallbackChecker 2016-08-18 12:40:21 +02:00
Florian Bruhin
359d4dd427 tests: Add a callback_checker fixture 2016-08-18 12:40:21 +02:00
Florian Bruhin
b1227391c5 tests: Request mode_manager in fake_web_tab
Since we create a HintManager in AbstractTab now, we need a ModeManager
present to use FakeWebTab.
2016-08-11 16:46:05 +02:00
Florian Bruhin
533319c1ae tests: Use dict.update in mode_manager fixture
This means we can use the fixture in tests which use config_stub
themselves.
2016-08-11 16:45:00 +02:00
Ryan Roden-Corrent
ffc5a42d04 Don't use objreg to get CompletionView.
The CompletionView is the parent of the Completer, so there's no need
to use objreg to get it.
See #640.
2016-07-28 12:20:24 -04:00
Ryan Roden-Corrent
a740f99607 Register the fake statusbar command in objreg.
The CompletionView looks in objreg for 'status-cmd', so move it from a
private fixture in test_completer to a public fixture that handles
objreg registration/deletion.
2016-07-28 12:20:24 -04:00
Florian Bruhin
a1c4e6e2cf Rename shadowed tmpdir variable 2016-07-20 16:13:46 +02:00
Ryan Roden-Corrent
7b3406a3e4 Use monkeypatch.setenv instead of os.putenv.
This ensures the environment is modified only for the test using the
fixture rather than for the whole test run.
2016-07-18 21:39:35 -04:00
Ryan Roden-Corrent
7d36847f77 Prevent test_tab from creating user data dir.
This is another case (like test_qt_javascript) that needs redirection
of XDG_DATA_HOME to prevent Qt from creating ~/.share/local/qute_test.
2016-07-17 07:07:05 -04:00
Ryan Roden-Corrent
a6695ea1be Prevent test_adblock from creating real config dir.
Don't create ~/.config/qute_test by mocking out standdarddir.config for
all tests in this module.

This adds config_tmpdir to fixtures.py and moves temp_datadir from
test_adblock to fixtures.py as it will be needed more broadly.
2016-07-15 13:46:50 -04:00
Florian Bruhin
f5359b67a2 tests: Fix default_config fixture
This wasn't used since the command tests were deactivated. It was broken
during some refactoring and nobody noticed.
2016-07-13 13:43:46 +02:00
Florian Bruhin
6a07d231f4 pykint: Add some disable=unused-variable 2016-07-11 13:18:31 +02:00
Florian Bruhin
86f381a3b7 Skip tests using fake_web_tab on PyQt < 5.6
For some weird reason they cause a segfault in QObject::disconnect since
fake_web_tab was converted to a fixture...

See #1638
2016-07-10 21:42:13 +02:00
Florian Bruhin
fd8e66136f tests: Add a mode_manager fixture 2016-07-10 17:04:25 +02:00
Florian Bruhin
2136d00aa2 tests: Add a fake_args fixture 2016-07-10 17:04:25 +02:00
Florian Bruhin
e36123735b Use a fixture for FakeWebTab
We need to make sure qapp and tab_registry are available everywhere the
FakeWebTab class is used.
2016-07-10 16:57:02 +02:00
Ryan Roden-Corrent
07edcce697 Unit test Completer.update_completion.
Validate update_completion sets the completions widget's model
correctly based on the command text.
2016-07-02 12:25:55 -04:00
Ryan Roden-Corrent
9d49f5a57d Test tab completion with multiple tabbed browsers. 2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
b6652ad6bc Test completion quickmark/bookmark deletion.
Validate that quickmarks and bookmarks can be deleted from the url
completion menu.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
16f043034f Unit test tab (buffer) completion.
This involved adding a few stubs as well as expanding the FakeWebView.
2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
610f9b7068 Unit test session completion 2016-06-30 07:26:02 -04:00
Ryan Roden-Corrent
baf8d00a20 Unit test url/quickmark/bookmark completion.
This also adds a few more stubs/fakes to mock out the
quickmark-manager, bookmark-manager, and web-history objects.
2016-06-30 07:26:02 -04:00
Florian Bruhin
4fccc89d7d Split browser into browser/browser.webkit 2016-06-13 11:18:21 +02:00
Florian Bruhin
33f01d8375 Fix lint 2016-06-09 21:14:03 +02:00
Florian Bruhin
789b9c9308 tests: Yield fake_save_manager from fixture 2016-06-09 17:44:04 +02:00
Florian Bruhin
75669dd21b tests: Move fake_save_manager to helper.fixtures 2016-06-09 17:44:04 +02:00
Florian Bruhin
ef2b3cd6d9 tests.helpers: Clean up imports 2016-06-09 17:44:04 +02:00
Florian Bruhin
483a5f8103 Fix sharing of cookie jars with private browsing
Fixes #1219
2016-06-08 16:35:43 +02:00
Florian Bruhin
520572321a Add unittests for partial command parsing 2016-06-06 16:18:49 +02:00
Florian Bruhin
5a5e8167dd Fix lint 2016-03-29 23:20:39 +02:00
Florian Bruhin
4067d38cb0 Add some tests for QtWebKit/Engine JS capabilities 2016-03-29 22:08:49 +02:00
Florian Bruhin
83dc390808 tests: Move fixtures into a separate file. 2016-02-04 07:27:23 +01:00