selfprivacy-rest-api/tests/common.py

29 lines
735 B
Python
Raw Normal View History

2022-06-24 21:14:20 +03:00
import json
2022-06-29 20:39:46 +03:00
from mnemonic import Mnemonic
2022-06-24 21:14:20 +03:00
2022-07-07 16:53:19 +03:00
2022-06-24 21:14:20 +03:00
def read_json(file_path):
with open(file_path, "r", encoding="utf-8") as file:
return json.load(file)
def write_json(file_path, data):
with open(file_path, "w", encoding="utf-8") as file:
json.dump(data, file, indent=4)
2022-06-29 20:39:46 +03:00
2022-07-07 16:53:19 +03:00
2022-06-29 20:39:46 +03:00
def generate_api_query(query_array):
return "query TestApi {\n api {" + "\n".join(query_array) + "}\n}"
2022-07-07 16:53:19 +03:00
2022-07-05 08:14:37 +03:00
def generate_system_query(query_array):
return "query TestSystem {\n system {" + "\n".join(query_array) + "}\n}"
2022-07-07 16:53:19 +03:00
def generate_users_query(query_array):
return "query TestUsers {\n users {" + "\n".join(query_array) + "}\n}"
2022-06-29 20:39:46 +03:00
def mnemonic_to_hex(mnemonic):
return Mnemonic(language="english").to_entropy(mnemonic).hex()