I have a CLI application and would like to incoportate testing but i have little experience in testing and none of this kind. Is there any recommended libraries or articles that anyone could recommend.
Provided below is an example method within the class Account. This class runs the command line and interacts with the established APIs and database (Flask with mongo-engine)
def name_check(self):
questions = [
{
'type': 'input',
'message': 'Enter Username',
'name': 'userName'
}
]
check_answers = prompt(questions, style=style)
# checkUser api-endpoint
check = "http://127.0.0.1:5000/authentication/checkUser/"
user_name_input = check_answers.get("userName")
# defining a params dict for the parameters to be sent to the API
PARAMS = {
"userName": user_name_input
}
acc_req = requests.post(url=check, json=PARAMS)
if acc_req.status_code == 200:
print("Account found, enter password:")
self.login(user_name_input)
else:
print("Account not found, enter password to create:")
self.register(user_name_input)
Aucun commentaire:
Enregistrer un commentaire