Skip to content

Commit

Permalink
Merge pull request #1469 from ScilifelabDataCentre/DDS-1668-Set-sto4_…
Browse files Browse the repository at this point in the history
…start_time-in-command-create_unit

Added sto4_start_time column to be initialized on unit creation
  • Loading branch information
rv0lt authored Sep 21, 2023
2 parents d10dcf7 + ed04fab commit 042adcd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions SPRINTLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,4 @@ _Nothing merged in CLI during this sprint_
- Bug fixed: Row in `ProjectUsers` should also be added if it doesn't exist when giving Researcher access to a specific project ([#1464](https://github.com/ScilifelabDataCentre/dds_web/pull/1464))
- Replace expired invites when there's a new invitation attempt ([#1466](https://github.com/ScilifelabDataCentre/dds_web/pull/1466))
- Workflow: Update PR template and clarify sections ([#1467](https://github.com/ScilifelabDataCentre/dds_web/pull/1467))
- Column `sto4_start_time` is automatically set when the create-unit command is run ([#1668])(https://scilifelab.atlassian.net/jira/software/projects/DDS/boards/13?selectedIssue=DDS-1668)
2 changes: 2 additions & 0 deletions dds_web/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def create_new_unit(
https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
"""
from dds_web.database import models
from dds_web.utils import current_time

error_message = ""
if len(public_id) > 50:
Expand All @@ -131,6 +132,7 @@ def create_new_unit(
external_display_name=external_display_name,
contact_email=contact_email,
internal_ref=internal_ref or public_id,
sto4_start_time=current_time(),
sto4_endpoint=safespring_endpoint,
sto4_name=safespring_name,
sto4_access=safespring_access,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,26 @@ def test_create_new_unit_success(client, runner, capfd: LogCaptureFixture) -> No
_, err = capfd.readouterr()
assert f"Unit '{correct_unit['name']}' created" in err

new_unit = (
db.session.query(models.Unit).filter(models.Unit.name == correct_unit["name"]).one_or_none()
)

# Check that the different attributes have been set up

assert new_unit.public_id == correct_unit["public_id"]
assert new_unit.external_display_name == correct_unit["external_display_name"]
assert new_unit.contact_email == correct_unit["contact_email"]
assert new_unit.internal_ref
assert new_unit.sto4_start_time
assert new_unit.sto4_endpoint == correct_unit["safespring_endpoint"]
assert new_unit.sto4_name == correct_unit["safespring_name"]
assert new_unit.sto4_access == correct_unit["safespring_access"]
assert new_unit.sto4_secret == correct_unit["safespring_secret"]
assert new_unit.days_in_available
assert new_unit.days_in_expired
assert new_unit.quota == correct_unit["quota"]
assert new_unit.warning_level


# update_unit

Expand Down

0 comments on commit 042adcd

Please sign in to comment.