-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependencies: version check on sqlite
C-language
#6567
base: main
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -98,3 +98,32 @@ def storage_cls(*args, **kwargs): | |||
result = run_cli_command(cmd_status.verdi_status, raises=True, use_subprocess=False) | ||||
assert 'Storage is corrupted' in result.output | ||||
assert result.exit_code is ExitCode.CRITICAL | ||||
|
||||
|
||||
def test_sqlite_version(run_cli_command, monkeypatch): | ||||
"""Test `verdi status` when the storage is found to be corrupt (e.g. non-matching repository UUIDs).""" | ||||
khsrali marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
profile = get_profile() | ||||
storage_backend = profile._attributes['storage']['backend'] | ||||
# This should be True, only if `pytest -m 'presto'` is used. | ||||
# and that is essential to guarantee the funtionality of the code! | ||||
if storage_backend in ['core.sqlite_dos', 'core.sqlite_zip']: | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this ever be the case though? If you really want to test this behavior in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this works as expected only in I've tried your suggestion to create a profile for each storage backend, but there is a strange problem there, which I don't understand. @pytest.mark.parametrize('entry_point', ('core.sqlite_zip', 'core.sqlite_dos', 'core.psql_dos'))
def test_sqlite_version(run_cli_command, monkeypatch, entry_point, tmp_path, config_psql_dos):
if entry_point == 'core.sqlite_zip':
tmp_path = tmp_path / 'archive.aiida'
create_archive([], filename=tmp_path)
if entry_point == 'core.psql_dos':
options = []
for key, value in config_psql_dos().items():
options.append(f'--{key.replace("_", "-")}')
options.append(str(value))
else:
options = ['--filepath', str(tmp_path)]
profile_name = f'temp-profile{entry_point}'
options = [entry_point, '-n', '--profile-name', profile_name, '--email', 'email@host', '--set-as-default', *options]
result = run_cli_command(cmd_profile.profile_setup, options, use_subprocess=True)
assert f'Created new profile `{profile_name}`.' in result.output
if entry_point in ['core.sqlite_dos', 'core.sqlite_zip']:
-> result = run_cli_command(cmd_status.verdi_status, use_subprocess=True, raises=True) This last line returns wrong results for some other profile, even if I While if you do this: (Pdb) import os
(Pdb) os.system("verdi status") returns the correct one: ✔ version: AiiDA v2.6.2.post0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite sure why it is not picking up the new profile. But anyway, this is not the way you probably want to go about this. You are now creating a profile in the test configuration. This can affect other tests. You probably want to create a new temporary isolated config, create the profile in that one, and just run the cli command in memory. See this test as an example of how to create the profile:
And then just run |
||||
# Should raise if installed version is lower than the supported one. | ||||
monkeypatch.setattr('aiida.storage.sqlite_zip.backend.SUPPORTED_VERSION', '100.0.0') | ||||
result = run_cli_command(cmd_status.verdi_status, use_subprocess=False, raises=True) | ||||
assert ( | ||||
'IncompatibleExternalDependencies: Storage backend requires sqlite 100.0.0 or higher. But you have' | ||||
in result.stderr | ||||
) | ||||
|
||||
# Should not raise if installed version is higher than the supported one. | ||||
monkeypatch.setattr('aiida.storage.sqlite_zip.backend.SUPPORTED_VERSION', '0.0.0') | ||||
result = run_cli_command(cmd_status.verdi_status, use_subprocess=False) | ||||
|
||||
else: | ||||
from unittest.mock import MagicMock | ||||
|
||||
mock_ = MagicMock() | ||||
monkeypatch.setattr('aiida.storage.sqlite_zip.backend.validate_sqlite_version', mock_) | ||||
result = run_cli_command(cmd_status.verdi_status, use_subprocess=False) | ||||
assert mock_.call_count == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was just to know if
profile setup
is failing, then I won't check whytest_delete_storage
is failing.(Only because
test_delete_storage
creates profiles, also with thesqlite
backend.)I've the habit of putting them in such order, maybe it doesn't matter that much...
I took the comment away, as this is not a most just easier to debug this way..