From 0f053ca7635737d7882a069f968493558aa32dfa Mon Sep 17 00:00:00 2001 From: Dariusz Kedzierski <dkedzierski@syncad.com> Date: Wed, 3 Jun 2020 11:06:58 +0200 Subject: [PATCH] Manual tests for list_comments --- tests/manual_tests/__init__.py | 0 ...ist_comments_by_author_last_update_test.py | 20 ++++++++++++++++ .../list_comments_by_cashout_test.py | 19 +++++++++++++++ .../list_comments_by_parent_test.py | 19 +++++++++++++++ .../manual_tests/list_comments_by_permlink.py | 19 +++++++++++++++ .../list_comments_by_root_test.py | 20 ++++++++++++++++ .../list_comments_by_update_test.py | 19 +++++++++++++++ tests/manual_tests/test_base.py | 24 +++++++++++++++++++ 8 files changed, 140 insertions(+) create mode 100644 tests/manual_tests/__init__.py create mode 100644 tests/manual_tests/list_comments_by_author_last_update_test.py create mode 100644 tests/manual_tests/list_comments_by_cashout_test.py create mode 100644 tests/manual_tests/list_comments_by_parent_test.py create mode 100644 tests/manual_tests/list_comments_by_permlink.py create mode 100644 tests/manual_tests/list_comments_by_root_test.py create mode 100644 tests/manual_tests/list_comments_by_update_test.py create mode 100644 tests/manual_tests/test_base.py diff --git a/tests/manual_tests/__init__.py b/tests/manual_tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/manual_tests/list_comments_by_author_last_update_test.py b/tests/manual_tests/list_comments_by_author_last_update_test.py new file mode 100644 index 000000000..d7c950f92 --- /dev/null +++ b/tests/manual_tests/list_comments_by_author_last_update_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +from .test_base import run_test + +if __name__ == '__main__': + reference_hive_node_url = 'https://api.hive.blog' + test_hive_node_url = 'http://127.0.0.1:8080' + + payload = { + "jsonrpc":"2.0", + "method":"database_api.list_comments", + "params" : { + "start" : ['steemit', '1970-01-01T00:00:00', '', ''], + "limit" : 10, + "order" : 'by_author_last_update' + }, + "id":1 + } + + run_test(reference_hive_node_url, test_hive_node_url, payload, ['author', 'permlink', 'updated_at']) diff --git a/tests/manual_tests/list_comments_by_cashout_test.py b/tests/manual_tests/list_comments_by_cashout_test.py new file mode 100644 index 000000000..69847e06e --- /dev/null +++ b/tests/manual_tests/list_comments_by_cashout_test.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 +from .test_base import run_test + +if __name__ == '__main__': + reference_hive_node_url = 'https://api.hive.blog' + test_hive_node_url = 'http://127.0.0.1:8080' + + payload = { + "jsonrpc":"2.0", + "method":"database_api.list_comments", + "params" : { + "start" : ['1970-01-01T00:00:00', '', ''], + "limit" : 10, + "order" : 'by_cashout_time' + }, + "id":1 + } + + run_test(reference_hive_node_url, test_hive_node_url, payload, ['author', 'permlink', 'parent_author', 'parent_permlink', 'created']) diff --git a/tests/manual_tests/list_comments_by_parent_test.py b/tests/manual_tests/list_comments_by_parent_test.py new file mode 100644 index 000000000..00a0ce719 --- /dev/null +++ b/tests/manual_tests/list_comments_by_parent_test.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 +from .test_base import run_test + +if __name__ == '__main__': + reference_hive_node_url = 'https://api.hive.blog' + test_hive_node_url = 'http://127.0.0.1:8080' + + payload = { + "jsonrpc":"2.0", + "method":"database_api.list_comments", + "params" : { + "start" : ['steemit', 'firstpost', '', ''], + "limit" : 10, + "order" : 'by_parent' + }, + "id":1 + } + + run_test(reference_hive_node_url, test_hive_node_url, payload, ['author', 'permlink', 'parent_author', 'parent_permlink', 'created']) diff --git a/tests/manual_tests/list_comments_by_permlink.py b/tests/manual_tests/list_comments_by_permlink.py new file mode 100644 index 000000000..a5ef3e333 --- /dev/null +++ b/tests/manual_tests/list_comments_by_permlink.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 +from .test_base import run_test + +if __name__ == '__main__': + reference_hive_node_url = 'https://api.hive.blog' + test_hive_node_url = 'http://127.0.0.1:8080' + + payload = { + "jsonrpc" : "2.0", + "method" : "database_api.list_comments", + "params" : { + "start" : ['', ''], + "limit" : 10, + "order" : 'by_permlink' + }, + "id" : 1 + } + + run_test(reference_hive_node_url, test_hive_node_url, payload, ['author', 'permlink']) diff --git a/tests/manual_tests/list_comments_by_root_test.py b/tests/manual_tests/list_comments_by_root_test.py new file mode 100644 index 000000000..5b9a6a092 --- /dev/null +++ b/tests/manual_tests/list_comments_by_root_test.py @@ -0,0 +1,20 @@ +#!/usr/bin/python3 +from .test_base import run_test + +if __name__ == '__main__': + reference_hive_node_url = 'https://api.hive.blog' + test_hive_node_url = 'http://127.0.0.1:8080' + + payload = { + "jsonrpc" : "2.0", + "method" : "database_api.list_comments", + "params" : { + "start" : ['steemit', 'firstpost', '', ''], + "limit" : 20, + "order" : 'by_root' + }, + "id":1 + } + + run_test(reference_hive_node_url, test_hive_node_url, payload, ['author', 'permlink', 'root_author', 'root_permlink', 'created']) + diff --git a/tests/manual_tests/list_comments_by_update_test.py b/tests/manual_tests/list_comments_by_update_test.py new file mode 100644 index 000000000..5c5bcd274 --- /dev/null +++ b/tests/manual_tests/list_comments_by_update_test.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 +from .test_base import run_test + +if __name__ == '__main__': + reference_hive_node_url = 'https://api.hive.blog' + test_hive_node_url = 'http://127.0.0.1:8080' + + payload = { + "jsonrpc":"2.0", + "method":"database_api.list_comments", + "params" : { + "start" : ['steemit', '1970-01-01T00:00:00', '', ''], + "limit" : 10, + "order" : 'by_update' + }, + "id":1 + } + + run_test(reference_hive_node_url, test_hive_node_url, payload, ['author', 'permlink', 'parent_author', 'parent_permlink', 'updated_at']) diff --git a/tests/manual_tests/test_base.py b/tests/manual_tests/test_base.py new file mode 100644 index 000000000..0e35eb29f --- /dev/null +++ b/tests/manual_tests/test_base.py @@ -0,0 +1,24 @@ +def run_test(reference_node_url, test_node_url, payload, table_keys): + import prettytable + from requests import post + from json import dumps + + print("Querying reference node") + resp = post(reference_node_url, dumps(payload)) + + json = resp.json() + table = prettytable.PrettyTable() + table.field_names = table_keys + for row in json['result']['comments']: + table.add_row([row[key] for key in table_keys]) + print(table) + + print("Querying test node") + resp = post(test_node_url, dumps(payload)) + + json = resp.json() + table = prettytable.PrettyTable() + table.field_names = table_keys + for row in json['result']: + table.add_row([row[key] for key in table_keys]) + print(table) -- GitLab