140681896Sopenharmony_ci#!/usr/bin/env python
240681896Sopenharmony_ci# -*- coding: utf-8 -*-
340681896Sopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd.
440681896Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
540681896Sopenharmony_ci# you may not use this file except in compliance with the License.
640681896Sopenharmony_ci# You may obtain a copy of the License at
740681896Sopenharmony_ci#
840681896Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
940681896Sopenharmony_ci#
1040681896Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
1140681896Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1240681896Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1340681896Sopenharmony_ci# See the License for the specific language governing permissions and
1440681896Sopenharmony_ci# limitations under the License.
1540681896Sopenharmony_ci
1640681896Sopenharmony_ciimport unittest
1740681896Sopenharmony_ci
1840681896Sopenharmony_cifrom log_exception import UPDATE_LOGGER
1940681896Sopenharmony_cifrom log_exception import handle_exception
2040681896Sopenharmony_cifrom log_exception import VendorExpandError
2140681896Sopenharmony_cifrom script_generator import Script
2240681896Sopenharmony_ci
2340681896Sopenharmony_ci
2440681896Sopenharmony_ciclass TestLogException(unittest.TestCase):
2540681896Sopenharmony_ci
2640681896Sopenharmony_ci    def setUp(self):
2740681896Sopenharmony_ci        print("set up")
2840681896Sopenharmony_ci
2940681896Sopenharmony_ci    def tearDown(self):
3040681896Sopenharmony_ci        print("tear down")
3140681896Sopenharmony_ci
3240681896Sopenharmony_ci    def test_print_log_error_type(self):
3340681896Sopenharmony_ci        """
3440681896Sopenharmony_ci        print_log, Input exception type
3540681896Sopenharmony_ci        :return:
3640681896Sopenharmony_ci        """
3740681896Sopenharmony_ci        UPDATE_LOGGER.print_log("Test log!", log_type="TEST_TYPE")
3840681896Sopenharmony_ci
3940681896Sopenharmony_ci    def test_handle_exception1(self):
4040681896Sopenharmony_ci        """
4140681896Sopenharmony_ci        handle_exception1, Exception occurred.
4240681896Sopenharmony_ci        :return:
4340681896Sopenharmony_ci        """
4440681896Sopenharmony_ci        vendor_error = VendorExpandError(type(Script), 'test_func')
4540681896Sopenharmony_ci        handle_exception(VendorExpandError, None, None)
4640681896Sopenharmony_ci        vendor_error.__str__()
4740681896Sopenharmony_ci
4840681896Sopenharmony_ci    def test_handle_exception2(self):
4940681896Sopenharmony_ci        """
5040681896Sopenharmony_ci        handle_exception2, Exception occurred.
5140681896Sopenharmony_ci        :return:
5240681896Sopenharmony_ci        """
5340681896Sopenharmony_ci        handle_exception(KeyboardInterrupt, None, None)
54