From ffd1b0d5c74da8dc8d90efa993ba6e922b095055 Mon Sep 17 00:00:00 2001 From: Florin Date: Thu, 8 Oct 2020 14:46:26 +0300 Subject: [PATCH 1/2] added the get_epoch_time operation --- .../base/datetime/get_epoch_time.sl | 29 +++++++++++++++++++ .../datetime/test_get_epoch_time_inputs.yaml | 7 +++++ 2 files changed, 36 insertions(+) create mode 100644 content/io/cloudslang/base/datetime/get_epoch_time.sl create mode 100644 test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml diff --git a/content/io/cloudslang/base/datetime/get_epoch_time.sl b/content/io/cloudslang/base/datetime/get_epoch_time.sl new file mode 100644 index 0000000000..d3a0142c92 --- /dev/null +++ b/content/io/cloudslang/base/datetime/get_epoch_time.sl @@ -0,0 +1,29 @@ +######################################################################################################################## +#!! +#! @description: Checks the current date and time, and returns its representation as an Epoch (Unix) timestamp. +#! +#! @output return_result: Current date and time in timestamp format. +#! @output return_code: 0 for success and 1 for failure. +#! +#! @result SUCCESS: Date/time retrieved successfully. +#! @result FAILURE: Date/time could not be retrieved. +#!!# +######################################################################################################################## +namespace: io.cloudslang.base.datetime +operation: + name: get_epoch_time + python_action: + script: |- + import time + try: + return_result = str(int(time.time())) + return_code = '0' + except: + return_result = sys.exc_info() + return_code = '1' + outputs: + - return_result + - return_code + results: + - SUCCESS: ${return_code == '0'} + - FAILURE diff --git a/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml b/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml new file mode 100644 index 0000000000..7021dabbaa --- /dev/null +++ b/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml @@ -0,0 +1,7 @@ +successTestGetEpochTime: + description: A successful test for get_epoch_time + testFlowPath: io.cloudslang.base.datetime.get_epoch_time + testSuites: [rest] + outputs: + - return_code: '0' + result: SUCCESS \ No newline at end of file From 25f6e8c3af1c7dcfdc78384900d350b212d2bda2 Mon Sep 17 00:00:00 2001 From: Florin Date: Thu, 8 Oct 2020 14:51:47 +0300 Subject: [PATCH 2/2] updated test suite --- .../io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml b/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml index 7021dabbaa..dcfe149f51 100644 --- a/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml +++ b/test/io/cloudslang/base/datetime/test_get_epoch_time_inputs.yaml @@ -1,7 +1,7 @@ successTestGetEpochTime: description: A successful test for get_epoch_time testFlowPath: io.cloudslang.base.datetime.get_epoch_time - testSuites: [rest] + testSuites: [datetime-local] outputs: - return_code: '0' result: SUCCESS \ No newline at end of file