Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
i-oden committed Jul 28, 2023
1 parent 4691961 commit 3af8ada
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions dds_web/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def delete_lost_files(project_id: str):

gc.collect()


@click.command("set-available-to-expired")
@flask.cli.with_appcontext
def set_available_to_expired():
Expand Down
12 changes: 7 additions & 5 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,7 @@ def test_delete_lost_files_no_project(client, cli_runner):
assert result.exit_code == 2
assert "Missing option '--project-id' / '-p'." in result.stdout


def test_delete_lost_files_project_nonexistent(client, cli_runner, capfd):
"""flask lost-files delete: no such project --> print out error."""
# Project -- doesn't exist
Expand Down Expand Up @@ -999,7 +1000,7 @@ def test_delete_lost_files_deleted(client, cli_runner, boto3_session, capfd):
# ------------------------------------------------------------------------

# Use sto2 -- start_time set, but project created before -----------------
# Set start_time
# Set start_time
project.responsible_unit.sto4_start_time = current_time()
db.session.commit()

Expand All @@ -1017,12 +1018,12 @@ def test_delete_lost_files_deleted(client, cli_runner, boto3_session, capfd):
# Verify output - files deleted
_, err = capfd.readouterr()
assert f"Files deleted from S3: 0" in err
assert f"Files deleted from DB: 0" in err # Already deleted
assert f"Files deleted from DB: 0" in err # Already deleted
assert f"Safespring location for project '{project.public_id}': sto2" in err
# ------------------------------------------------------------------------

# Use sto2 -- start_time set, project created after, but all vars not set
# Set start_time
# Set start_time
project.responsible_unit.sto4_start_time = current_time() - relativedelta(hours=1)
db.session.commit()

Expand All @@ -1047,7 +1048,7 @@ def test_delete_lost_files_deleted(client, cli_runner, boto3_session, capfd):
# ------------------------------------------------------------------------

# Use sto4 - start_time set, project created after and all vars set ------
# Set start_time
# Set start_time
project.responsible_unit.sto4_endpoint = "endpoint"
project.responsible_unit.sto4_name = "name"
project.responsible_unit.sto4_access = "access"
Expand All @@ -1069,12 +1070,13 @@ def test_delete_lost_files_deleted(client, cli_runner, boto3_session, capfd):
# Verify output - files deleted
_, err = capfd.readouterr()
assert f"Files deleted from S3: 0" in err
assert f"Files deleted from DB: 0" in err # Aldready deleted
assert f"Files deleted from DB: 0" in err # Aldready deleted
assert f"Safespring location for project '{project.public_id}': sto2" not in err
assert f"Safespring location for project '{project.public_id}': sto4" in err
assert f"One or more sto4 variables are missing for unit {unit.public_id}." not in err
# ------------------------------------------------------------------------


def test_delete_lost_files_sqlalchemyerror(client, cli_runner, boto3_session, capfd):
"""flask lost-files delete: sqlalchemyerror during deletion."""
# Imports
Expand Down

0 comments on commit 3af8ada

Please sign in to comment.