diff --git a/tests/tavern/common.yaml b/tests/tavern/common.yaml new file mode 100644 index 0000000000000000000000000000000000000000..313a8be3b22c52d3c2224ec3924308e8bf6712fe --- /dev/null +++ b/tests/tavern/common.yaml @@ -0,0 +1,9 @@ +--- + name: Common test values + description: Common values for tests + + variables: + service: + proto: http + server: "{tavern.env_vars.REPTRACKER_ADDRESS}" + port: "{tavern.env_vars.REPTRACKER_PORT}" diff --git a/tests/tavern/get_rep_last_synced_block/block_hash.pat.json b/tests/tavern/get_rep_last_synced_block/block_hash.pat.json new file mode 100644 index 0000000000000000000000000000000000000000..d4375a28ae7ddb7c18c90c3cd94389381c0b2ffc --- /dev/null +++ b/tests/tavern/get_rep_last_synced_block/block_hash.pat.json @@ -0,0 +1 @@ +5000000 \ No newline at end of file diff --git a/tests/tavern/get_rep_last_synced_block/block_hash.tavern.yaml b/tests/tavern/get_rep_last_synced_block/block_hash.tavern.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eb43d7e3c826491d632a391f30a7d7fee2ac8bb0 --- /dev/null +++ b/tests/tavern/get_rep_last_synced_block/block_hash.tavern.yaml @@ -0,0 +1,21 @@ +--- + test_name: reptracker PostgREST + + marks: + - patterntest + + includes: + - !include ../common.yaml + + stages: + - name: test + request: + url: "{service.proto:s}://{service.server:s}:{service.port}/rpc/get_rep_last_synced_block" + method: POST + headers: + content-type: application/json + accept: application/json + response: + status_code: 200 + verify_response_with: + function: validate_response:compare_rest_response_with_pattern diff --git a/tests/tavern/get_reputation/blocktrades.pat.json b/tests/tavern/get_reputation/blocktrades.pat.json new file mode 100644 index 0000000000000000000000000000000000000000..8c0474e3239fc7c1a693d29caba0c85b872b6c1d --- /dev/null +++ b/tests/tavern/get_reputation/blocktrades.pat.json @@ -0,0 +1 @@ +69 \ No newline at end of file diff --git a/tests/tavern/get_reputation/blocktrades.tavern.yaml b/tests/tavern/get_reputation/blocktrades.tavern.yaml new file mode 100644 index 0000000000000000000000000000000000000000..03156653bf3f32cf820cd1600194abcfcbd45740 --- /dev/null +++ b/tests/tavern/get_reputation/blocktrades.tavern.yaml @@ -0,0 +1,23 @@ +--- + test_name: reptracker PostgREST + + marks: + - patterntest + + includes: + - !include ../common.yaml + + stages: + - name: test + request: + url: "{service.proto:s}://{service.server:s}:{service.port}/rpc/get_account_reputation" + method: POST + headers: + content-type: application/json + accept: application/json + json: + account-name: "blocktrades" + response: + status_code: 200 + verify_response_with: + function: validate_response:compare_rest_response_with_pattern \ No newline at end of file diff --git a/tests/tavern/get_reputation/gtg.pat.json b/tests/tavern/get_reputation/gtg.pat.json new file mode 100644 index 0000000000000000000000000000000000000000..f0b5c72cad2a31240e128db4bc833e782855f796 --- /dev/null +++ b/tests/tavern/get_reputation/gtg.pat.json @@ -0,0 +1 @@ +57 \ No newline at end of file diff --git a/tests/tavern/get_reputation/gtg.tavern.yaml b/tests/tavern/get_reputation/gtg.tavern.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9383c2bc4a3ba8740bd0c660e86692ecfc43850a --- /dev/null +++ b/tests/tavern/get_reputation/gtg.tavern.yaml @@ -0,0 +1,23 @@ +--- + test_name: reptracker PostgREST + + marks: + - patterntest + + includes: + - !include ../common.yaml + + stages: + - name: test + request: + url: "{service.proto:s}://{service.server:s}:{service.port}/rpc/get_account_reputation" + method: POST + headers: + content-type: application/json + accept: application/json + json: + account-name: "gtg" + response: + status_code: 200 + verify_response_with: + function: validate_response:compare_rest_response_with_pattern \ No newline at end of file diff --git a/tests/tavern/get_reputation/non_existent_account.pat.json b/tests/tavern/get_reputation/non_existent_account.pat.json new file mode 100644 index 0000000000000000000000000000000000000000..fe05f12926fbb4e09ab1025ad6ca3dcc8b974bbc --- /dev/null +++ b/tests/tavern/get_reputation/non_existent_account.pat.json @@ -0,0 +1,6 @@ +{ + "code": "P0001", + "details": null, + "hint": null, + "message": "Account 'themarkymark' does not exist" +} \ No newline at end of file diff --git a/tests/tavern/get_reputation/non_existent_account.tavern.yaml b/tests/tavern/get_reputation/non_existent_account.tavern.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b2a154b978b266eef4fbbc61fbdda427f8025d27 --- /dev/null +++ b/tests/tavern/get_reputation/non_existent_account.tavern.yaml @@ -0,0 +1,26 @@ +--- + test_name: reptracker PostgREST + + marks: + - patterntest + - negative + + includes: + - !include ../common.yaml + + stages: + - name: test + request: + url: "{service.proto:s}://{service.server:s}:{service.port}/rpc/get_account_reputation" + method: POST + headers: + content-type: application/json + accept: application/json + json: + account-name: "themarkymark" + response: + status_code: 400 + verify_response_with: + function: validate_response:compare_rest_response_with_pattern + extra_kwargs: + error_response: true diff --git a/tests/tavern/pytest.ini b/tests/tavern/pytest.ini new file mode 100644 index 0000000000000000000000000000000000000000..6bdcaf0471a1dec2eb35e36847f9d0fe62facf1a --- /dev/null +++ b/tests/tavern/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +markers = + patterntest: Mark tests using patterns to compare results + negative: Mark error tests