Changeset View
Changeset View
Standalone View
Standalone View
swh/core/db/tests/test_cli.py
Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | def test_cli_swh_db_upgrade_new_api(cli_runner, postgresql, datadir, mocker, tmp_path): | ||||
# custom version of the mockup to make it easy to change the | # custom version of the mockup to make it easy to change the | ||||
# current_version returned by get_current_version() | # current_version returned by get_current_version() | ||||
# TODO: find a better solution for this... | # TODO: find a better solution for this... | ||||
def import_swhmodule_mock(modname): | def import_swhmodule_mock(modname): | ||||
if modname.startswith("test."): | if modname.startswith("test."): | ||||
dirname = modname.split(".", 1)[1] | dirname = modname.split(".", 1)[1] | ||||
def get_datastore(cls, **kw): | def get_datastore(cls, **kw): | ||||
return mocker.MagicMock(current_version=current_version) | return mocker.MagicMock(get_current_version=lambda: current_version) | ||||
return mocker.MagicMock( | return mocker.MagicMock( | ||||
__name__=modname, | __name__=modname, | ||||
__file__=os.path.join(datadir, dirname, "__init__.py"), | __file__=os.path.join(datadir, dirname, "__init__.py"), | ||||
name=modname, | name=modname, | ||||
get_datastore=get_datastore, | get_datastore=get_datastore, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |