# Path: can4python/canframe_definition.py
# class CanFrameDefinition():
#     def __init__(self, frame_id, name='', dlc=constants.MAX_NUMBER_OF_CAN_DATA_BYTES, cycletime=None,
#                  frame_format=constants.CAN_FRAMEFORMAT_STANDARD):
#     def __repr__(self, long_text=True):
#     def frame_id(self):
#     def frame_id(self, value):
#     def dlc(self):
#     def dlc(self, value):
#     def cycletime(self):
#     def cycletime(self, value):
#     def throttle_time(self):
#     def throttle_time(self, value):
#     def frame_format(self):
#     def frame_format(self, value):
#     def producer_ids(self):
#     def producer_ids(self, value):
#     def get_descriptive_ascii_art(self):
#     def get_signal_mask(self):
#     def is_outbound(self, ego_node_ids):
# 
# Path: can4python/configuration.py
# class Configuration():
#     def __init__(self, framedefinitions=None, busname=None, ego_node_ids=None):
#     def ego_node_ids(self):
#     def ego_node_ids(self, value):
#     def __repr__(self):
#     def get_descriptive_ascii_art(self):
#     def add_framedefinition(self, framedef):
#     def set_throttle_times(self, inputdict):
#     def set_throttle_times_from_signalnames(self, inputdict):
#     def set_receive_on_change_only(self, inputlist):
#     def set_receive_on_change_only_from_signalnames(self, inputlist):
#     def find_frameid_from_signalname(self, input_signalname):
# 
# Path: can4python/exceptions.py
# class CanException(Exception):
# class CanTimeoutException(CanException):
# class CanNotFoundByKernelException(CanException):
# 
# Path: can4python/filehandler_kcd.py
# class FilehandlerKcd():
#     def read(filename, busname=None):
#     def write(config, filename):


import contextlib
import copy
import os
import sys
import unittest
from can4python import canframe_definition
from can4python import configuration
from can4python import exceptions
from can4python import filehandler_kcd
    from .test_configuration import FRAME_ID_SEND, TESTCONFIG1
    from test_configuration import FRAME_ID_SEND, TESTCONFIG1
        self.assertEqual(config.framedefinitions[1].signaldefinitions[3].defaultvalue, 20)
        self.assertEqual(config.framedefinitions[1].signaldefinitions[3].unit, 'm/s')
        self.assertEqual(config.framedefinitions[1].signaldefinitions[3].comment, "Test signal number 4")

        fr_def = config.framedefinitions[0x12345678]
        self.assertEqual(fr_def.frame_id, 0x12345678)
        self.assertEqual(fr_def.name, 'testframedef2')
        self.assertEqual(fr_def.dlc, 4)
        self.assertEqual(fr_def.frame_format, 'extended')
        self.assertEqual(fr_def.cycletime, 50)
        self.assertEqual(len(fr_def.signaldefinitions), 1)

        self.assertEqual(fr_def.signaldefinitions[0].signalname, 'testsignal21')
        self.assertEqual(fr_def.signaldefinitions[0].startbit, 5)
        self.assertEqual(fr_def.signaldefinitions[0].numberofbits, 1)
        self.assertEqual(fr_def.signaldefinitions[0].scalingfactor, 1)
        self.assertEqual(fr_def.signaldefinitions[0].valueoffset, 0)
        self.assertEqual(fr_def.signaldefinitions[0].endianness, 'little')
        self.assertEqual(fr_def.signaldefinitions[0].signaltype, 'unsigned')
        self.assertEqual(fr_def.signaldefinitions[0].minvalue, None)
        self.assertEqual(fr_def.signaldefinitions[0].maxvalue, None)
        self.assertEqual(fr_def.signaldefinitions[0].defaultvalue, 0)
        self.assertEqual(fr_def.signaldefinitions[0].unit, "")
        self.assertEqual(fr_def.signaldefinitions[0].comment, "")

    def testReadKcdFileFaulty(self):
        self.assertRaises(exceptions.CanException,
                          filehandler_kcd.FilehandlerKcd.read, self.input_filename_no_busdefinition, None)

    def testReadKcdFileWrongBusname(self):

# Path: can4python/canframe_definition.py
# class CanFrameDefinition():
#     def __init__(self, frame_id, name='', dlc=constants.MAX_NUMBER_OF_CAN_DATA_BYTES, cycletime=None,
#                  frame_format=constants.CAN_FRAMEFORMAT_STANDARD):
#     def __repr__(self, long_text=True):
#     def frame_id(self):
#     def frame_id(self, value):
#     def dlc(self):
#     def dlc(self, value):
#     def cycletime(self):
#     def cycletime(self, value):
#     def throttle_time(self):
#     def throttle_time(self, value):
#     def frame_format(self):
#     def frame_format(self, value):
#     def producer_ids(self):
#     def producer_ids(self, value):
#     def get_descriptive_ascii_art(self):
#     def get_signal_mask(self):
#     def is_outbound(self, ego_node_ids):
# 
# Path: can4python/configuration.py
# class Configuration():
#     def __init__(self, framedefinitions=None, busname=None, ego_node_ids=None):
#     def ego_node_ids(self):
#     def ego_node_ids(self, value):
#     def __repr__(self):
#     def get_descriptive_ascii_art(self):
#     def add_framedefinition(self, framedef):
#     def set_throttle_times(self, inputdict):
#     def set_throttle_times_from_signalnames(self, inputdict):
#     def set_receive_on_change_only(self, inputlist):
#     def set_receive_on_change_only_from_signalnames(self, inputlist):
#     def find_frameid_from_signalname(self, input_signalname):
# 
# Path: can4python/exceptions.py
# class CanException(Exception):
# class CanTimeoutException(CanException):
# class CanNotFoundByKernelException(CanException):
# 
# Path: can4python/filehandler_kcd.py
# class FilehandlerKcd():
#     def read(filename, busname=None):
#     def write(config, filename):


# Path: tests/test_filehandler_kcd.py
import contextlib
import copy
import os
import sys
import unittest
from can4python import canframe_definition
from can4python import configuration
from can4python import exceptions
from can4python import filehandler_kcd
    from .test_configuration import FRAME_ID_SEND, TESTCONFIG1
    from test_configuration import FRAME_ID_SEND, TESTCONFIG1

        self.assertEqual(config.framedefinitions[1].signaldefinitions[3].defaultvalue, 20)
        self.assertEqual(config.framedefinitions[1].signaldefinitions[3].unit, 'm/s')
        self.assertEqual(config.framedefinitions[1].signaldefinitions[3].comment, "Test signal number 4")

        fr_def = config.framedefinitions[0x12345678]
        self.assertEqual(fr_def.frame_id, 0x12345678)
        self.assertEqual(fr_def.name, 'testframedef2')
        self.assertEqual(fr_def.dlc, 4)
        self.assertEqual(fr_def.frame_format, 'extended')
        self.assertEqual(fr_def.cycletime, 50)
        self.assertEqual(len(fr_def.signaldefinitions), 1)

        self.assertEqual(fr_def.signaldefinitions[0].signalname, 'testsignal21')
        self.assertEqual(fr_def.signaldefinitions[0].startbit, 5)
        self.assertEqual(fr_def.signaldefinitions[0].numberofbits, 1)
        self.assertEqual(fr_def.signaldefinitions[0].scalingfactor, 1)
        self.assertEqual(fr_def.signaldefinitions[0].valueoffset, 0)
        self.assertEqual(fr_def.signaldefinitions[0].endianness, 'little')
        self.assertEqual(fr_def.signaldefinitions[0].signaltype, 'unsigned')
        self.assertEqual(fr_def.signaldefinitions[0].minvalue, None)
        self.assertEqual(fr_def.signaldefinitions[0].maxvalue, None)
        self.assertEqual(fr_def.signaldefinitions[0].defaultvalue, 0)
        self.assertEqual(fr_def.signaldefinitions[0].unit, "")
        self.assertEqual(fr_def.signaldefinitions[0].comment, "")

    def testReadKcdFileFaulty(self):
        self.assertRaises(exceptions.CanException,
                          filehandler_kcd.FilehandlerKcd.read, self.input_filename_no_busdefinition, None)

    def testReadKcdFileWrongBusname(self):

        self.assertRaises(exceptions.CanException,