From 10fe025782a36f9f45218da44472b239ebe10032 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Tue, 19 Sep 2023 14:00:48 +0200 Subject: [PATCH 1/8] added start time --- dds_web/commands.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dds_web/commands.py b/dds_web/commands.py index a69c45e2b..6fff6efa3 100644 --- a/dds_web/commands.py +++ b/dds_web/commands.py @@ -106,7 +106,8 @@ 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: error_message = "The 'public_id' can be a maximum of 50 characters" @@ -139,6 +140,7 @@ def create_new_unit( days_in_expired=days_in_expired, quota=quota, warning_level=warn_at, + sto4_start_time = current_time() ) db.session.add(new_unit) db.session.commit() From dffb18aa0e23eef0ceb113ec6d6d6596ac6f080a Mon Sep 17 00:00:00 2001 From: rv0lt Date: Tue, 19 Sep 2023 14:05:55 +0200 Subject: [PATCH 2/8] sprintlog --- SPRINTLOG.md | 1 + dds_web/commands.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SPRINTLOG.md b/SPRINTLOG.md index 77700d4e5..0189c2dbe 100644 --- a/SPRINTLOG.md +++ b/SPRINTLOG.md @@ -300,3 +300,4 @@ _Nothing merged in CLI during this sprint_ - Dependency: Bump `MariaDB` to LTS version 10.11.5 ([#1465](https://github.com/ScilifelabDataCentre/dds_web/pull/1465)) - 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)) - 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) diff --git a/dds_web/commands.py b/dds_web/commands.py index 6fff6efa3..4a1e34ba4 100644 --- a/dds_web/commands.py +++ b/dds_web/commands.py @@ -107,7 +107,7 @@ def create_new_unit( """ from dds_web.database import models from dds_web.utils import current_time - + error_message = "" if len(public_id) > 50: error_message = "The 'public_id' can be a maximum of 50 characters" @@ -140,7 +140,7 @@ def create_new_unit( days_in_expired=days_in_expired, quota=quota, warning_level=warn_at, - sto4_start_time = current_time() + sto4_start_time=current_time(), ) db.session.add(new_unit) db.session.commit() From cd81f8aa17f2a4a5fab6ac02b88cc46434f0df58 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Thu, 21 Sep 2023 13:58:29 +0200 Subject: [PATCH 3/8] feedback --- dds_web/commands.py | 2 +- tests/test_commands.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dds_web/commands.py b/dds_web/commands.py index 4a1e34ba4..08bc8f84b 100644 --- a/dds_web/commands.py +++ b/dds_web/commands.py @@ -132,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, @@ -140,7 +141,6 @@ def create_new_unit( days_in_expired=days_in_expired, quota=quota, warning_level=warn_at, - sto4_start_time=current_time(), ) db.session.add(new_unit) db.session.commit() diff --git a/tests/test_commands.py b/tests/test_commands.py index 734d8b2f8..4b479b760 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -252,6 +252,9 @@ 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() + + assert new_unit.sto4_start_time # update_unit From 2f652c5f8c5337a6a9e640d27d6b26f1c1223c99 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Thu, 21 Sep 2023 14:01:13 +0200 Subject: [PATCH 4/8] black --- dds_web/commands.py | 2 +- tests/test_commands.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dds_web/commands.py b/dds_web/commands.py index 08bc8f84b..c9d925cb3 100644 --- a/dds_web/commands.py +++ b/dds_web/commands.py @@ -132,7 +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_start_time=current_time(), sto4_endpoint=safespring_endpoint, sto4_name=safespring_name, sto4_access=safespring_access, diff --git a/tests/test_commands.py b/tests/test_commands.py index 4b479b760..e44b57e68 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -252,10 +252,13 @@ 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() + new_unit = ( + db.session.query(models.Unit).filter(models.Unit.name == correct_unit["name"]).one_or_none() + ) assert new_unit.sto4_start_time + # update_unit From da5f521ebee1b0e0d6ae2eabf48ed883f377341c Mon Sep 17 00:00:00 2001 From: rv0lt Date: Thu, 21 Sep 2023 14:43:07 +0200 Subject: [PATCH 5/8] more test conditions --- tests/test_commands.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index e44b57e68..4f82dd869 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -256,7 +256,21 @@ def test_create_new_unit_success(client, runner, capfd: LogCaptureFixture) -> No 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 From 1bc6d10d90e1d6d268e86f34d92605ddc6f62b0d Mon Sep 17 00:00:00 2001 From: rv0lt Date: Thu, 21 Sep 2023 15:19:52 +0200 Subject: [PATCH 6/8] sto2 endpoints --- tests/test_commands.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index 4f82dd869..1cd5310f1 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -272,6 +272,11 @@ def test_create_new_unit_success(client, runner, capfd: LogCaptureFixture) -> No assert new_unit.quota == correct_unit["quota"] assert new_unit.warning_level + # check for the atributes that should not be setted up + assert not new_unit.sto2_endpoint + assert not new_unit.sto2_name + assert not new_unit.sto2_access + assert not new_unit.sto2_secret # update_unit From d1fa7f25e4f33af2a60f72d40d398b4cfaff2b4f Mon Sep 17 00:00:00 2001 From: rv0lt Date: Thu, 21 Sep 2023 15:23:34 +0200 Subject: [PATCH 7/8] black --- tests/test_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index 1cd5310f1..4985b5041 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -278,6 +278,7 @@ def test_create_new_unit_success(client, runner, capfd: LogCaptureFixture) -> No assert not new_unit.sto2_access assert not new_unit.sto2_secret + # update_unit From ed04fabd37a354207d5e0b5993e545213daa36f7 Mon Sep 17 00:00:00 2001 From: rv0lt Date: Thu, 21 Sep 2023 15:27:36 +0200 Subject: [PATCH 8/8] removed unncesary checks --- tests/test_commands.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 4985b5041..4f82dd869 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -272,12 +272,6 @@ def test_create_new_unit_success(client, runner, capfd: LogCaptureFixture) -> No assert new_unit.quota == correct_unit["quota"] assert new_unit.warning_level - # check for the atributes that should not be setted up - assert not new_unit.sto2_endpoint - assert not new_unit.sto2_name - assert not new_unit.sto2_access - assert not new_unit.sto2_secret - # update_unit