test_case.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # -*- coding: UTF-8 -*-
  2. """
  3. @Project :pytest_src
  4. @File :test_case.py
  5. @Author :haojiang
  6. @Date :2022/9/23 10:09
  7. """
  8. import logging
  9. import allure
  10. import pytest
  11. from Base.MatrixParser import MatrixParser
  12. from Base.SignalInitTableCheck import MatrixSignalInitValueCheck, SignalValueCheck, SignalInitValueTableCheck, \
  13. SignalAttrType
  14. from Base.Utils import get_arxml_path
  15. # MATRIX_PATH = r'E:\Project\EP39EREV\EP39_erev v1.1a\GW'
  16. MATRIX_PATH = r'E:\Project\EC32\V1.1b\20220513-zw5_EC32_EP_V02_GW'
  17. arxml_path = get_arxml_path(MATRIX_PATH)
  18. print(arxml_path)
  19. mp = MatrixParser(arxml_path)
  20. # r'E:\Project\EP39\EP39_GW04_V1.1a_20220628_Integation\InputFiles\MA_20220607_qy1_EP39EV_simu_GWC-arxmal-V01.1.arxml')
  21. mc = MatrixSignalInitValueCheck()
  22. all_data = mc.get_signal_attr_data_by_dataframe(mp.all_dataframe['ISignal'])
  23. def test_01_csv_check():
  24. '''
  25. CSV 初值表 信号有效性检查,包括初值缺失、格式及值是否超出范围。
  26. :return:
  27. '''
  28. sc = SignalInitValueTableCheck(MATRIX_PATH)
  29. data = sc.get_signal_init_value_table()
  30. ret = True
  31. for row in data:
  32. # sc.check_row(row)
  33. scb = SignalValueCheck(row)
  34. ret_status, ret_code = scb.check_attribute()
  35. if not ret_status:
  36. ret = False
  37. assert True == ret
  38. # @pytest.mark.parametrize("signal_attr", all_data)
  39. # def test_02_matrix_signal_check(signal_attr: dict):
  40. # white_list = ['_NM_', 'NKI', 'NWI']
  41. # sc = SignalValueCheck(signal_attr)
  42. # ret, ret_code = sc.check_attribute()
  43. #
  44. # if ret_code == 1:
  45. # for word in white_list:
  46. # if word in signal_attr[SignalAttrType.SIGNAL_NAME.name]:
  47. # ret = True
  48. #
  49. # assert True == ret
  50. def test_02_matrix_signal_check():
  51. '''
  52. 通信矩阵 系统信号有效性检查,包括初值缺失、格式及值是否超出范围。
  53. 当初值缺失时,需进一步信号名是否在白名单内。当前NM-PDU中包含的信号,处于白名单。
  54. :return:
  55. '''
  56. ret = True
  57. white_list = ['_NM_', 'NKI', 'NWI']
  58. for row in all_data:
  59. # sc.check_row(row)
  60. scb = SignalValueCheck(row)
  61. ret_status, ret_code = scb.check_attribute()
  62. if ret_code == 1:
  63. for word in white_list:
  64. if word in row[SignalAttrType.SIGNAL_NAME.name]:
  65. ret_status = True
  66. if not ret_status:
  67. ret = False
  68. assert True == ret
  69. def test_03_matrix_dcm_pdu_name_check():
  70. dcm_pdu_df = mp.all_dataframe['Dcm_IPdu']
  71. criterion = dcm_pdu_df['PDU Name'].str.contains('Phys') | dcm_pdu_df['PDU Name'].str.contains('Fun')
  72. ret = criterion.all()
  73. if not ret:
  74. logging.error('DCM PDU Name should include Phys!')
  75. logging.error(dcm_pdu_df['PDU Name'])
  76. assert True == ret
  77. def test_04_matrix_dcm_pdu_length_check():
  78. dcm_pdu_df = mp.all_dataframe['Dcm_IPdu']
  79. criterion = dcm_pdu_df['PDU Length'].isin(['7', '4095'])
  80. # print(criterion)
  81. ret = criterion.all()
  82. if not ret:
  83. logging.error('DCM PDU Length must is 7 or 4095!')
  84. logging.error(dcm_pdu_df[['PDU Name', 'PDU Length']])
  85. assert True == ret
  86. def test_05_matrix_contained_pdu_header_id_check():
  87. ipdu_df = mp.all_dataframe['IPdu']
  88. criterion = ipdu_df['Contained PDU ID'] == '0'
  89. ret = ~(criterion.all())
  90. if not ret:
  91. logging.error('Contained Pdu id must not be 0!')
  92. logging.error(ipdu_df[['PDU Name', 'Contained PDU ID']])
  93. assert True == ret