Skip to content
Merged
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
24 changes: 20 additions & 4 deletions framework/python/src/common/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def apply_session_tracker(cls):
setattr(cls, attr, session_tracker(getattr(cls, attr)))
return cls


@apply_session_tracker
class TestrunSession():
"""Represents the current session of Testrun."""
Expand Down Expand Up @@ -127,6 +126,7 @@ def __init__(self, root_dir):

# System network interfaces
self._ifaces = {}

# Loading methods
self._load_version()
self._load_config()
Expand Down Expand Up @@ -478,15 +478,30 @@ def _load_profiles(self):
encoding='utf-8') as f:

# Parse risk profile json
json_data = json.load(f)
json_data: dict = json.load(f)

# Validate profile JSON
if not self.validate_profile_json(json_data):
LOGGER.error('Profile failed validation')
continue

# Instantiate a new risk profile
risk_profile = RiskProfile()
risk_profile: RiskProfile = RiskProfile()

questions: list[dict] = json_data.get('questions')

# Remove any additional (outdated questions from the profile)
for question in questions:

# Check if question exists in the profile format
if self.get_profile_format_question(
question=question.get('question')) is None:

# Remove question from profile
questions.remove(question)

# Pass questions back to the risk profile
json_data['questions'] = questions

# Pass JSON to populate risk profile
risk_profile.load(profile_json=json_data,
Expand Down Expand Up @@ -605,7 +620,8 @@ def validate_profile_json(self, profile_json):

if format_q is None:
LOGGER.error(f'Unrecognized question: {question.get("question")}')
return False
# Just ignore additional questions
continue

# Error handling if 'answer' is missing
if 'answer' not in question and valid:
Expand Down