Skip to content
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

add delete-problem command to ramp-database #564

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/whats_new/v0.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ Version 0.10 (ongoing)
Changelog
---------

TODO: specify the module before to add the desired entry.
`ramp-database`
...............

- Add `delete-problem` command in database cli :pr:`564`
19 changes: 17 additions & 2 deletions ramp-database/ramp_database/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,21 @@ def add_submission(config, event, team, submission, path):
submission_module.add_submission(session, event, team, submission, path)


@main.command()
@click.option(
"--config",
default="config.yml",
show_default=True,
help="Configuration file YAML format containing the database information",
)
@click.option("--problem", help="Name of the problem")
def delete_problem(config, problem):
"""Delete problem."""
config = read_config(config)
with session_scope(config["sqlalchemy"]) as session:
event_module.delete_problem(session, problem)


@main.command()
@click.option(
"--config",
Expand All @@ -307,7 +322,7 @@ def add_submission(config, event, team, submission, path):
"--config-event",
required=True,
help="Path to configuration file YAML format "
"containing the database information, eg config.yml",
"containing the event information, eg config.yml",
)
@click.option(
"--dry-run",
Expand Down Expand Up @@ -380,7 +395,7 @@ def delete_event(config, config_event, dry_run, from_disk, force):
"--config-event",
required=True,
help="Path to configuration file YAML format "
"containing the database information, eg config.yml",
"containing the event information, eg config.yml",
)
@click.option(
"--force",
Expand Down
34 changes: 34 additions & 0 deletions ramp-database/ramp_database/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,40 @@ def test_add_event(make_toy_db):
assert result.exit_code == 0, result.output


def test_delete_problem(make_toy_db):
runner = CliRunner()
ramp_config = read_config(ramp_config_template())
runner.invoke(
main,
[
"add-problem",
"--config",
database_config_template(),
"--problem",
"iris",
"--kit-dir",
ramp_config["ramp_kit_dir"],
"--data-dir",
ramp_config["ramp_data_dir"],
"--force",
True,
],
catch_exceptions=False,
)
result = runner.invoke(
main,
[
"delete-problem",
"--config",
database_config_template(),
"--problem",
"iris",
],
catch_exceptions=False,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance you can assess in the database that the problem is available after you add it and then gone once you remove it? see how it's done elsewhere.

assert result.exit_code == 0, result.output


@pytest.mark.parametrize("from_disk", [True, False])
@pytest.mark.parametrize("force", [True, False])
def test_delete_event_error(make_toy_db, from_disk, force):
Expand Down