From 3993195150b180a56c357caf54aedd3ef56faf6c Mon Sep 17 00:00:00 2001 From: arkuz Date: Mon, 17 Dec 2018 17:28:03 +0300 Subject: [PATCH] added tests for DateTime and CmpTime functions --- fixtures/pages.json | 32 +++++++++++++++++++++++++++ fixtures/simvolio.yaml | 22 +++++++++++++++++++ test_protypo.py | 50 ++++++++++++++++++++++++++++++++++++++++++ test_simvolio.py | 9 ++++++++ 4 files changed, 113 insertions(+) diff --git a/fixtures/pages.json b/fixtures/pages.json index d133eee..65a47c2 100644 --- a/fixtures/pages.json +++ b/fixtures/pages.json @@ -905,5 +905,37 @@ "code": "ArrayToSource(dat, [\"hello\", \"my name\",\"is Billy\"])", "menu": "default_menu", "content": {} + }, + "datetime": { + "code": "DateTime(\"2018-07-23 05:54:10\", \"HH:MI:SS DD.MM.YYYY\")", + "menu": "default_menu", + "content": { + "tag": "text", + "text": "05:54:10 23.07.2018" + } + }, + "datetimeUnix": { + "code": "DateTime(\"1532325250\", \"HH:MI:SS DD.MM.YYYY\")", + "menu": "default_menu", + "content": { + "tag": "text", + "text": "05:54:10 23.07.2018" + } + }, + "cmpTime": { + "code": "SetVar(d, \"1532325250\") CmpTime(\"1532325250\", \"#d#\")", + "menu": "default_menu", + "content": { + "tag": "text", + "text": "0" + } + }, + "cmpTimeUnix": { + "code": "SetVar(d, \"05:54:10 23.07.2018\") CmpTime(\"#d#\", \"05:54:10 23.07.2018\")", + "menu": "default_menu", + "content": { + "tag": "text", + "text": "0" + } } } \ No newline at end of file diff --git a/fixtures/simvolio.yaml b/fixtures/simvolio.yaml index 5ce73fa..82d74bb 100644 --- a/fixtures/simvolio.yaml +++ b/fixtures/simvolio.yaml @@ -1098,3 +1098,25 @@ UpdateRolesNotifications: } } asert: "True" + + +datetime: + code: | + { + data {} + action { + $result = DateTime(1532325250) + } + } + asert: "2018-07-23 05:54:10" + + +unixdatetime: + code: | + { + data {} + action { + $result = UnixDateTime("2018-07-23 05:54:10") + } + } + asert: "1532325250" \ No newline at end of file diff --git a/test_protypo.py b/test_protypo.py index 0321ee3..36b3e3a 100644 --- a/test_protypo.py +++ b/test_protypo.py @@ -1037,3 +1037,53 @@ def test_transactionInfo(self): expected_str = '"contract":"@1NewContract","params":{"ApplicationId":1' self.uni.assertIn(expected_str, str(part_content), 'transactionInfo has problem: ' + str(content['tree'])) + + def test_page_datetime(self): + cont = self.pages['datetime'] + content = self.check_page(cont['code']) + part_content = content['tree'][0] + contract_content = cont['content'] + must_be = dict(tag=part_content['tag'], + text=part_content['text']) + page = dict(tag=contract_content['tag'], + text=contract_content['text']) + self.uni.assertDictEqual(must_be, page, + 'datetime has problem: ' + str(content['tree'])) + + def test_page_datetimeUnix(self): + # returns datetime in timezone in which the node is running + cont = self.pages['datetimeUnix'] + content = self.check_page(cont['code']) + part_content = content['tree'][0] + contract_content = cont['content'] + must_be = dict(tag=part_content['tag'], + text=part_content['text']) + page = dict(tag=contract_content['tag'], + text=contract_content['text']) + self.uni.assertDictEqual(must_be, page, + 'datetimeUnix has problem: ' + str(content['tree'])) + + def test_page_cmpTime(self): + cont = self.pages['cmpTime'] + content = self.check_page(cont['code']) + part_content = content['tree'][0] + contract_content = cont['content'] + must_be = dict(tag=part_content['tag'], + text=part_content['text']) + page = dict(tag=contract_content['tag'], + text=contract_content['text']) + self.uni.assertDictEqual(must_be, page, + 'cmpTime has problem: ' + str(content['tree'])) + + def test_page_cmpTimeUnix(self): + cont = self.pages['cmpTimeUnix'] + content = self.check_page(cont['code']) + part_content = content['tree'][0] + contract_content = cont['content'] + must_be = dict(tag=part_content['tag'], + text=part_content['text']) + page = dict(tag=contract_content['tag'], + text=contract_content['text']) + self.uni.assertDictEqual(must_be, page, + 'cmpTimeUnix has problem: ' + str(content['tree'])) + diff --git a/test_simvolio.py b/test_simvolio.py index 413b0c5..0d2a2aa 100644 --- a/test_simvolio.py +++ b/test_simvolio.py @@ -698,3 +698,12 @@ def test_contract_UpdateNotifications(self): def test_contract_UpdateRolesNotifications(self): contract = self.contracts['UpdateRolesNotifications'] self.check_contract(contract['code'], contract['asert']) + + def test_contract_datetime(self): + # returns datetime in timezone in which the node is running + contract = self.contracts['datetime'] + self.check_contract(contract['code'], contract['asert']) + + def test_contract_unixdatetime(self): + contract = self.contracts['unixdatetime'] + self.check_contract(contract['code'], contract['asert']) \ No newline at end of file