def test_MPFConfigFile_mergedconfig(self):
        
        test_dict = dict()
        test_dict['hardware'] = dict()
        test_dict['hardware']['platform'] = 'smart_virtual'
        test_dict['hardware']['driverboards'] = 'virtual'
        test_dict['hardware']['dmd'] = 'smartmatrix'
        test_dict['coils'] = dict()
        test_dict['coils']['c_flipper_left_main'] = dict()
        test_dict['coils']['c_flipper_left_main']['number'] = 0
        test_dict['coils']['c_flipper_left_hold'] = dict()
        test_dict['coils']['c_flipper_left_hold']['number'] = 1
        
        root_config = dict()
        root_config['hardware'] = dict()
        root_config['hardware']['platform'] = 'smart_virtual'
        root_config['hardware']['driverboards'] = 'virtual'
        root_config['hardware']['dmd'] = 'smartmatrix'
        root_config_file = MPFConfigFile('rootfile.yaml', root_config)

        child_config = dict()
        child_config['coils'] = dict()
        child_config['coils']['c_flipper_left_main'] = dict()
        child_config['coils']['c_flipper_left_main']['number'] = 0
        child_config['coils']['c_flipper_left_hold'] = dict()
        child_config['coils']['c_flipper_left_hold']['number'] = 1
        child_config_file = MPFConfigFile('childfile.yaml', child_config)
        
        root_config_file.add_child_file(child_config_file)
        
        merged_dict = root_config_file.get_merged_config()
        
        self.assertDictEqual(merged_dict, test_dict)
        
Пример #2
0
    def _load_config_file(self, filename, verify_version=True, halt_on_error=True):
        config_file = MPFConfigFile(filename, FileManager.load(filename, verify_version, halt_on_error, True))

        try:
            if 'config' in config_file.config:
                path = os.path.split(filename)[0]

                for file in Util.string_to_list(config_file.config['config']):
                    full_file = os.path.join(path, file)
                    new_config = self._load_config_file(full_file)
                    config_file.add_child_file(new_config)
            return config_file
        except TypeError:
            return dict()
Пример #3
0
    def test_MPFConfigFile_mergedconfig(self):

        test_dict = dict()
        test_dict['hardware'] = dict()
        test_dict['hardware']['platform'] = 'smart_virtual'
        test_dict['hardware']['driverboards'] = 'virtual'
        test_dict['hardware']['dmd'] = 'smartmatrix'
        test_dict['coils'] = dict()
        test_dict['coils']['c_flipper_left_main'] = dict()
        test_dict['coils']['c_flipper_left_main']['number'] = 0
        test_dict['coils']['c_flipper_left_hold'] = dict()
        test_dict['coils']['c_flipper_left_hold']['number'] = 1

        root_config = dict()
        root_config['hardware'] = dict()
        root_config['hardware']['platform'] = 'smart_virtual'
        root_config['hardware']['driverboards'] = 'virtual'
        root_config['hardware']['dmd'] = 'smartmatrix'
        root_config_file = MPFConfigFile('rootfile.yaml', root_config)

        child_config = dict()
        child_config['coils'] = dict()
        child_config['coils']['c_flipper_left_main'] = dict()
        child_config['coils']['c_flipper_left_main']['number'] = 0
        child_config['coils']['c_flipper_left_hold'] = dict()
        child_config['coils']['c_flipper_left_hold']['number'] = 1
        child_config_file = MPFConfigFile('childfile.yaml', child_config)

        root_config_file.add_child_file(child_config_file)

        merged_dict = root_config_file.get_merged_config()

        self.assertDictEqual(merged_dict, test_dict)