コード例 #1
0
    def test_reboot_cause(self):
        from sonic_platform import utils
        from sonic_platform.chassis import REBOOT_CAUSE_ROOT
        chassis = Chassis()
        major, minor = chassis.get_reboot_cause()
        assert major == chassis.REBOOT_CAUSE_NON_HARDWARE
        assert minor == ''

        mock_file_content = {}

        def read_int_from_file(file_path, *args, **kwargs):
            return mock_file_content[file_path]

        utils.read_int_from_file = read_int_from_file

        for key, value in chassis.reboot_major_cause_dict.items():
            file_path = os.path.join(REBOOT_CAUSE_ROOT, key)
            mock_file_content[file_path] = 1
            major, minor = chassis.get_reboot_cause()
            assert major == value
            assert minor == ''
            mock_file_content[file_path] = 0

        for key, value in chassis.reboot_minor_cause_dict.items():
            file_path = os.path.join(REBOOT_CAUSE_ROOT, key)
            mock_file_content[file_path] = 1
            major, minor = chassis.get_reboot_cause()
            assert major == chassis.REBOOT_CAUSE_HARDWARE_OTHER
            assert minor == value
            mock_file_content[file_path] = 0
コード例 #2
0
def test_chassis_info():
    chassis = Chassis()
    assert chassis.get_presence() is True
    assert chassis.get_status() is True
    reboot = chassis.get_reboot_cause()
    print("reboot_casue: {}".format(reboot))
    assert reboot != ''
    assert chassis.is_modular_chassis() is True
    slot = chassis.get_supervisor_slot()
    print("supervisor slot: {}".format(slot))
    assert slot == nokia_common.NOKIA_CPM_SLOT_NUMBER
    slot = chassis.get_my_slot()
    print("my slot: {}".format(slot))
    assert slot != ''