-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathapi_tests.py
38 lines (31 loc) · 1.34 KB
/
api_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pytest
from flask import json
from app import app
@pytest.fixture
def client():
app.config['TESTING'] = True
with app.test_client() as client:
yield client
def test_home(client):
response = client.get('/')
assert response.data == b'Welcome to the Blockchain API!'
def test_mint_tokens(client):
response = client.post('/mint', json={'recipient': '0xRecipientAddress', 'amount': 100})
assert response.status_code == 200
assert response.json['message'] == "Tokens minted successfully."
def test_burn_tokens(client):
response = client.post('/burn', json={'amount': 50})
assert response.status_code == 200
assert response.json['message'] == "Tokens burned successfully."
def test_create_proposal(client):
response = client.post('/create_proposal', json={'description': 'Increase token supply'})
assert response.status_code == 200
assert response.json['message'] == "Proposal created successfully."
def test_vote(client):
response = client.post('/vote', json={'proposal_id': 1})
assert response.status_code == 200
assert response.json['message'] == "Vote cast successfully."
def test_execute_proposal(client):
response = client.post('/execute_proposal', json={'proposal_id': 1})
assert response.status_code == 200
assert response.json['message'] == "Proposal executed successfully."