:param text: Input to convert.
:type text: str or unicode
:returns: Converted text.
:rtype: str
"""
:param text: Input to convert.
:type text: str or unicode
:returns: Converted text.
:rtype: str
"""
"""Holder of data related to tracking VPP API CRCs.
Both message names and crc hexa strings are tracked as
"""Holder of data related to tracking VPP API CRCs.
Both message names and crc hexa strings are tracked as
- ordinary Python2 (bytes) string, so _str() is used when input is
- possibly unicode or otherwise not safe.
+ ordinary Python3 (unicode) string, so _str() is used when input is
+ possibly bytes or otherwise not safe.
Each instance of this class starts with same default state,
so make sure the calling libraries have appropriate robot library scope.
Each instance of this class starts with same default state,
so make sure the calling libraries have appropriate robot library scope.
If an incompatible CRC is found, affected collections are removed.
A CRC that would remove all does not, added to _reported instead,
while causing a failure in single test (if fail_on_mismatch)."""
If an incompatible CRC is found, affected collections are removed.
A CRC that would remove all does not, added to _reported instead,
while causing a failure in single test (if fail_on_mismatch)."""
"""Log to console, on fail_on_mismatch also raise runtime exception.
:param exc_msg: The message to include in log or exception.
"""Log to console, on fail_on_mismatch also raise runtime exception.
:param exc_msg: The message to include in log or exception.
:raises RuntimeError: With the message, if fail_on_mismatch.
"""
logger.console("RuntimeError:\n{m}".format(m=exc_msg))
:raises RuntimeError: With the message, if fail_on_mismatch.
"""
logger.console("RuntimeError:\n{m}".format(m=exc_msg))
mapping = {_str(k): _str(v) for k, v in name_to_crc_mapping.items()}
self._expected[collection_name] = mapping
self._missing[collection_name] = mapping.copy()
mapping = {_str(k): _str(v) for k, v in name_to_crc_mapping.items()}
self._expected[collection_name] = mapping
self._missing[collection_name] = mapping.copy()
"""Add all collections this CSIT codebase is tested against."""
file_path = os.path.normpath(os.path.join(
"""Add all collections this CSIT codebase is tested against."""
file_path = os.path.normpath(os.path.join(
- os.path.dirname(os.path.abspath(__file__)), "..", "..",
- "api", "vpp", "supported_crcs.yaml"))
+ os.path.dirname(os.path.abspath(__file__)), u"..", u"..",
+ u"api", u"vpp", u"supported_crcs.yaml"))
for collection_name, name_to_crc_mapping in collections_dict.items():
self._register_collection(collection_name, name_to_crc_mapping)
for collection_name, name_to_crc_mapping in collections_dict.items():
self._register_collection(collection_name, name_to_crc_mapping)
for item in reversed(msg_obj):
if not isinstance(item, dict):
continue
for item in reversed(msg_obj):
if not isinstance(item, dict):
continue
def _process_crc(self, api_name, crc):
"""Compare API to verified collections, update class state.
def _process_crc(self, api_name, crc):
"""Compare API to verified collections, update class state.
for msg_obj in msgs:
msg_name = self._get_name(msg_obj)
msg_crc = self._get_crc(msg_obj)
self._process_crc(msg_name, msg_crc)
for msg_obj in msgs:
msg_name = self._get_name(msg_obj)
msg_crc = self._get_crc(msg_obj)
self._process_crc(msg_name, msg_crc)
def report_initial_conflicts(self, report_missing=False):
"""Report issues discovered by _check_dir, if not done that already.
def report_initial_conflicts(self, report_missing=False):
"""Report issues discovered by _check_dir, if not done that already.
- self._reported, indent=1, sort_keys=True, separators=[",", ":"])
+ self._reported, indent=1, sort_keys=True,
+ separators=[u",", u":"]
+ )
if not report_missing:
return
missing = {name: mapp for name, mapp in self._missing.items() if mapp}
if missing:
missing_indented = json.dumps(
if not report_missing:
return
missing = {name: mapp for name, mapp in self._missing.items() if mapp}
if missing:
missing_indented = json.dumps(
- missing, indent=1, sort_keys=True, separators=[",", ":"])
- self.log_and_raise("API CRCs missing from .api.json:\n{mi}".format(
- mi=missing_indented))
+ missing, indent=1, sort_keys=True, separators=[u",", u":"])
+ self.log_and_raise(
+ f"API CRCs missing from .api.json:\n{missing_indented}"
+ )
def check_api_name(self, api_name):
"""Fail if the api_name has no, or different from known CRC associated.
def check_api_name(self, api_name):
"""Fail if the api_name has no, or different from known CRC associated.
Do not fail if this particular failure has been already reported.
Intended use: Call during test (not in initialization),
Do not fail if this particular failure has been already reported.
Intended use: Call during test (not in initialization),