Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update phrase "url" to "urls" and update error handling #421

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from testflinger_device_connectors.devices import ProvisioningError
from testflinger_device_connectors.devices.zapper_iot.parser import (
validate_provision_plan,
validate_url,
validate_urls,
)

logger = logging.getLogger(__name__)
Expand All @@ -44,9 +44,11 @@ def _validate_configuration(
raise ProvisioningError from e

try:
url = self.job_data["provision_data"]["url"]
validate_url(url)
urls = self.job_data["provision_data"]["urls"]
validate_urls(urls)
except KeyError:
url = []
urls = []
except ValueError as e:
raise ProvisioningError from e

return ((provision_plan, url), {})
return ((provision_plan, urls), {})
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,13 @@ def validate_provision_plan(data):
validate(instance=data, schema=TPLAN_SCHEMA)
logger.info("the JSON data is valid")
except jsonschema.exceptions.ValidationError as err:
logger.info("the JSON data is invalid")
raise ValueError("the JSON data is invalid") from err


def validate_url(url):
def validate_urls(urls):
"""for verify url"""
for link in url:
for link in urls:
if not validators.url(link):
logger.info("url %s is invalid", link)
raise ValueError("url format is not correct")