Created validations for the cases where user doesn't have any skills or the user doesn't have the skill installer

pull/9/head
Matheus Lima 2018-10-26 17:45:38 -03:00
parent 8dad2343a7
commit c19ae24161
1 changed files with 16 additions and 5 deletions

View File

@ -66,11 +66,22 @@ class SkillInstallEndpoint(SeleneEndpoint):
def _find_installer_skill(self, installed_skills):
installer_skill = None
for skill in installed_skills['skills']:
if skill['skill']['name'] == 'Installer':
self.device_uuid = skill['deviceUuid']
installer_skill = skill['skill']
break
if "skills" in installed_skills:
for skill in installed_skills['skills']:
if skill['skill']['name'] == 'Installer':
self.device_uuid = skill['deviceUuid']
installer_skill = skill['skill']
break
if installer_skill is None:
error_message = (
'found no skill installer'
)
_log.error(error_message)
self.response = (error_message, HTTPStatus.PARTIAL_CONTENT)
raise APIError()
else:
self.response = HTTPStatus.NO_CONTENT
raise APIError()
return installer_skill