Merge "Improvement to SystemTableParser"

This commit is contained in:
Zuul 2025-02-19 17:33:53 +00:00 committed by Gerrit Code Review
commit 6165897ebb
2 changed files with 36 additions and 1 deletions

View File

@ -42,8 +42,12 @@ class SystemTableParser:
for line in self.system_output:
# Skip lines that aren't part of the table.
if not (line.startswith("|") or line.__contains__("+--")):
continue
# We have hit a separator which enters Headers, Content, or Ends the table
if line.__contains__('+'):
if line.__contains__('+--'):
# Find out in which part of the table we are, based on the "+----" separator.
if not is_in_headers_block and not is_in_content_block: # First separator -> Enter Headers

View File

@ -164,6 +164,23 @@ system_application_upload = [
"Please use 'system application-list' or 'system application-show hello-kitty' to view the current progress.\n",
]
system_oam_show_output = [
'system oam-show\n',
'\x1b[?2004l+----------------+--------------------------------------+',
'| Property | Value |\n',
'+----------------+--------------------------------------+\n',
'| created_at | 2025-02-18T18:36:41.267146+00:00 |\n',
'| isystem_uuid | 572d2cb4-f5ee-449a-899c-e5a9582147f9 |\n',
'| oam_end_ip | 10.66.77.254 |\n',
'| oam_gateway_ip | 10.66.77.1 |\n',
'| oam_ip | 10.66.77.234 |\n',
'| oam_start_ip | 10.66.77.1 |\n',
'| oam_subnet | 10.66.77.0/24 |\n',
'| updated_at | None |\n',
'| uuid | 920531a8-55f0-4263-c8cf-6938965f5d45 |\n',
'+----------------+--------------------------------------+\n',
]
system_host_if_ptp_remove_wrapped_output = [
'+--------------------------------------+---------+-----------+---------------+\n',
'| uuid | name | ptp_insta | parameters |\n',
@ -198,6 +215,20 @@ def test_system_parser():
assert output['operational'] == 'enabled'
assert output['availability'] == 'available'
def test_system_parser_with_text_after():
"""
Tests the system parser
Returns:
"""
system_table_parser = SystemTableParser(system_oam_show_output)
output_list = system_table_parser.get_output_values_list()
assert len(output_list) == 9
assert output_list[0]['Property'] == 'created_at'
assert output_list[0]['Value'] == '2025-02-18T18:36:41.267146+00:00'
assert output_list[8]['Property'] == 'uuid'
assert output_list[8]['Value'] == '920531a8-55f0-4263-c8cf-6938965f5d45'
def test_system_parser_application_list_output():
"""