Skip to content

Commit

Permalink
PsqlDosBackend: Add missing repository_uri to the model (aiidatea…
Browse files Browse the repository at this point in the history
…m#6342)

The field not being declared means an option for it was not added to the
dynamically generated `verdi profile setup core.psql_dos`. This would
cause the command to fail as the initialization of the storage would
raise an error complaining about the missing `repository_uri`. This was
missed because the `core.psql_dos` storage was excluded from the
parametrized test for the `verdi profile setup` command but this is now
added.
  • Loading branch information
sphuber authored Apr 7, 2024
1 parent b01038b commit 43a7d77
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/aiida/storage/psql_dos/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ class Model(BaseModel):
database_name: str = Field(
title='PostgreSQL database name', description='The name of the database in the PostgreSQL server.'
)
repository_uri: str = Field(
title='File repository URI',
description='URI to the file repository.',
)

migrator = PsqlDosMigrator

Expand Down
14 changes: 11 additions & 3 deletions tests/cmdline/commands/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def test_delete_storage(run_cli_command, isolated_config, tmp_path, entry_point)
assert profile_name not in isolated_config.profile_names


@pytest.mark.parametrize('entry_point', ('core.sqlite_temp', 'core.sqlite_dos', 'core.sqlite_zip'))
def test_setup(run_cli_command, isolated_config, tmp_path, entry_point):
@pytest.mark.parametrize('entry_point', ('core.psql_dos', 'core.sqlite_temp', 'core.sqlite_dos', 'core.sqlite_zip'))
def test_setup(config_psql_dos, run_cli_command, isolated_config, tmp_path, entry_point):
"""Test the ``verdi profile setup`` command.
Note that the options for user name and institution are not given on purpose as these should not be required.
Expand All @@ -177,8 +177,16 @@ def test_setup(run_cli_command, isolated_config, tmp_path, entry_point):
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()['storage']['config'].items():
options.append(f'--{key.replace("_", "-")}')
options.append(str(value))
else:
options = ['--filepath', str(tmp_path)]

profile_name = 'temp-profile'
options = [entry_point, '-n', '--filepath', str(tmp_path), '--profile', profile_name, '--email', 'email@host']
options = [entry_point, '-n', '--profile', profile_name, '--email', 'email@host', *options]
result = run_cli_command(cmd_profile.profile_setup, options, use_subprocess=False)
assert f'Created new profile `{profile_name}`.' in result.output
assert profile_name in isolated_config.profile_names
Expand Down

0 comments on commit 43a7d77

Please sign in to comment.