2022-03-30 19:16:39 +00:00
|
|
|
import aqt
|
2018-05-07 01:45:56 +00:00
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
from conftest import ac, anki_connect_config_loaded, \
|
|
|
|
set_up_test_deck_and_test_model_and_two_notes, \
|
|
|
|
current_decks_and_models_etc_preserved, wait
|
2017-08-29 04:21:32 +00:00
|
|
|
|
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
# version is retrieved from config
|
|
|
|
def test_version(session_with_profile_loaded):
|
|
|
|
with anki_connect_config_loaded(
|
|
|
|
session=session_with_profile_loaded,
|
|
|
|
web_bind_port=0,
|
|
|
|
):
|
|
|
|
assert ac.version() == 6
|
2018-05-07 01:45:56 +00:00
|
|
|
|
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
def test_reloadCollection(setup):
|
|
|
|
ac.reloadCollection()
|
2020-05-01 18:38:23 +00:00
|
|
|
|
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
class TestProfiles:
|
|
|
|
def test_getProfiles(self, session_with_profile_loaded):
|
|
|
|
result = ac.getProfiles()
|
2022-04-07 22:35:42 +00:00
|
|
|
assert result == ["test_user"]
|
2018-05-07 01:45:56 +00:00
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
# waiting a little while gets rid of the cryptic warning:
|
|
|
|
# Qt warning: QXcbConnection: XCB error: 8 (BadMatch), sequence: 658,
|
|
|
|
# resource id: 2097216, major code: 42 (SetInputFocus), minor code: 0
|
|
|
|
def test_loadProfile(self, session_with_profile_loaded):
|
|
|
|
aqt.mw.unloadProfileAndShowProfileManager()
|
|
|
|
wait(0.1)
|
2022-04-07 22:35:42 +00:00
|
|
|
ac.loadProfile(name="test_user")
|
2020-04-22 01:22:10 +00:00
|
|
|
|
2020-05-01 18:55:30 +00:00
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
class TestExportImport:
|
|
|
|
def test_exportPackage(self, session_with_profile_loaded, setup):
|
|
|
|
filename = session_with_profile_loaded.base + "/export.apkg"
|
|
|
|
ac.exportPackage(deck="test_deck", path=filename)
|
2020-07-12 19:53:31 +00:00
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
def test_importPackage(self, session_with_profile_loaded):
|
|
|
|
filename = session_with_profile_loaded.base + "/export.apkg"
|
2018-05-07 01:45:56 +00:00
|
|
|
|
2022-03-30 19:16:39 +00:00
|
|
|
with current_decks_and_models_etc_preserved():
|
|
|
|
set_up_test_deck_and_test_model_and_two_notes()
|
|
|
|
ac.exportPackage(deck="test_deck", path=filename)
|
|
|
|
|
|
|
|
with current_decks_and_models_etc_preserved():
|
|
|
|
assert "test_deck" not in ac.deckNames()
|
|
|
|
ac.importPackage(path=filename)
|
|
|
|
assert "test_deck" in ac.deckNames()
|