Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
t_stationtest_parser.py 2.53 KiB
import unittest
from .. import station_test_raw_parser as raw_parser
import os
from .common import *


class TestStationTestsParser(unittest.TestCase):
    def test_parsing_one_test(self):
        station_test_data = read_station_test_data()
        first_test = raw_parser.split_history_into_tests(station_test_data)[0]
        self.assertEqual(first_test[-1],
                         "20130522,HBA,036,E_FAIL,SPX9=1,SPY9=1,SPX10=1,SPY10=1,SPX13=1,SPY13=1,SPX14=1,SPY14=1")

    def test_all_test_dict_parsing(self):
        station_test_data = read_station_test_data()

        for test in raw_parser.split_history_into_tests(station_test_data):
            result = raw_parser.dict_from_raw_station_test(test)
            for component in result['components_error']:
                self.assertIn('resourcetype', component)

    def test_component_to_dict_parsing(self):
        SPU_error_strings = {'hba': "20150903,SPU,002,VOLTAGE,HBA-48V=44.9",
                             'rcu': "20150903,SPU,002,VOLTAGE,RCU-5.0V=44.9",
                             'lba': "20150903,SPU,002,VOLTAGE,LBA-8.0V=44.9",
                             'spu': "20150903,SPU,002,VOLTAGE,SPU-3.3V=44.9"}
                             ## Test SPU parsing
        for key, SPU_error_string in SPU_error_strings.items():
            parsed_content = raw_parser.dict_from_component_error(split_rows_as_expected(SPU_error_string))
            for key in ['resourcetype', 'voltage_'+key]:
                self.assertIn(key, parsed_content)

        LBA_error_strings = {'LBAFlatError': '20180215,LBH,018,FLAT,Ymean=64.4',
                             'LBADownError': '20180215,LBH,019,DOWN,X=81.6,Y=59.0,Xoff=-14,Yoff=-2',
                             'LBADownError': '20180215,LBH,022,DOWN,X=58.8,Y=77.3,Xoff=-2,Yoff=-16'}
        # Test LBA parsing
        for key, LBA_error_string in LBA_error_strings.items():
            parsed_content = raw_parser.dict_from_component_error(split_rows_as_expected(LBA_error_string))
            self.assertIn('resourcetype', parsed_content)
            self.assertEqual(parsed_content['resourcetype'], key)

        HBA_error_strings = {'HBAModemError': '20180215,HBA,020,MODEM,E03=??,E05=??,E13=??',}
        # Test HBA parsing
        for key, HBA_error_string in HBA_error_strings.items():
            parsed_content = raw_parser.dict_from_component_error(split_rows_as_expected(HBA_error_string))

            self.assertIn('resourcetype', parsed_content)
            self.assertEqual(parsed_content['resourcetype'], key)

if __name__=='__main__':
    unittest.main()