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

[IS-11] Adding 'valid' verification to Fix issue 790 #816

Merged
merged 4 commits into from
Jun 20, 2023
Merged
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
2 changes: 2 additions & 0 deletions nmostesting/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@
# Bash shell to use for running testssl.sh
TEST_SSL_BASH = "bash"

# Stability delay for any request on IS-11
STABLE_STATE_DELAY = 3
# Definition of each API specification and its versions.
SPECIFICATIONS = {
"is-04": {
Expand Down
98 changes: 98 additions & 0 deletions nmostesting/IS11Utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Copyright (C) 2022 Advanced Media Workflow Association
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from . import TestHelper
from .NMOSUtils import NMOSUtils


class IS11Utils(NMOSUtils):
def __init__(self, url):
NMOSUtils.__init__(self, url)

# TODO: Remove the duplication (IS05Utils)
def get_senders(self):
"""Gets a list of the available senders on the API"""
toReturn = []
valid, r = TestHelper.do_request("GET", self.url + "senders/")
if valid and r.status_code == 200:
try:
for value in r.json():
toReturn.append(value[:-1])
except ValueError:
pass
return toReturn

# TODO: Remove the duplication (IS05Utils)
def get_receivers(self):
"""Gets a list of the available receivers on the API"""
toReturn = []
valid, r = TestHelper.do_request("GET", self.url + "receivers/")
if valid and r.status_code == 200:
try:
for value in r.json():
toReturn.append(value[:-1])
except ValueError:
pass
return toReturn

# TODO: Remove the duplication (IS05Utils)
def get_inputs(self):
"""Gets a list of the available inputs on the API"""
toReturn = []
valid, r = TestHelper.do_request("GET", self.url + "inputs/")
if valid and r.status_code == 200:
try:
for value in r.json():
toReturn.append(value[:-1])
except ValueError:
pass
return toReturn

# TODO: Remove the duplication (IS05Utils)
def get_outputs(self):
"""Gets a list of the available outputs on the API"""
toReturn = []
valid, r = TestHelper.do_request("GET", self.url + "outputs/")
if valid and r.status_code == 200:
try:
for value in r.json():
toReturn.append(value[:-1])
except ValueError:
pass
return toReturn

# TODO: Remove the duplication (IS05Utils)
def checkCleanRequest(self, method, dest, data=None, code=200):
"""Checks a request can be made and the resulting json can be parsed"""
status, response = TestHelper.do_request(method, self.url + dest, json=data)
if not status:
return status, response

message = "Expected status code {} from {}, got {}.".format(code, dest, response.status_code)
if response.status_code == code:
return True, response
else:
return False, message

# TODO: Remove the duplication (IS05Utils)
def checkCleanRequestJSON(self, method, dest, data=None, code=200):
valid, response = self.checkCleanRequest(method, dest, data, code)
if valid:
try:
return True, response.json()
except Exception:
# Failed parsing JSON
return False, "Invalid JSON received"
else:
return valid, response
Loading