示例#1
0
 def test_import_text(self):
     import yaml
     self.filename = util.rel_to_file('import_test/parent_text.yaml')
     self.control_filename = util.rel_to_file('import_test/control_text.yaml')
     data = cfg.yaml_load_file(self.filename)
     control = cfg.yaml_load_file(self.control_filename)
     self.assertEqual(data, control)
示例#2
0
 def test_import_text(self):
     import yaml
     self.filename = util.rel_to_file('import_test/parent_text.yaml')
     self.control_filename = util.rel_to_file(
         'import_test/control_text.yaml')
     data = cfg.yaml_load_file(self.filename)
     control = cfg.yaml_load_file(self.control_filename)
     self.assertEqual(data, control)
示例#3
0
 def test_import(self):
     import yaml
     self.filename = util.rel_to_file('import_test/parent.yaml')
     self.control_filename = util.rel_to_file('import_test/control.yaml')
     data = cfg.yaml_load_file(self.filename)
     print repr(data)
     self.assertIn('child1', data)
     child1 = data['child1']
     self.assertIs(type(child1), dict)
     self.assertIn('child2', child1)
     child2 = child1['child2']
     self.assertIs(type(child2), dict)
     self.assertIn('dataaa', child2)
     self.assertEqual(child2['dataaa'], 'this is it')
     control = cfg.yaml_load_file(self.control_filename)
     self.assertEqual(data, control)
示例#4
0
 def test_import(self):
     import yaml
     self.filename = util.rel_to_file('import_test/parent.yaml')
     self.control_filename = util.rel_to_file('import_test/control.yaml')
     data = cfg.yaml_load_file(self.filename)
     print repr(data)
     self.assertIn('child1', data)
     child1 = data['child1']
     self.assertIs(type(child1), dict)
     self.assertIn('child2', child1)
     child2 = child1['child2']
     self.assertIs(type(child2), dict)
     self.assertIn('dataaa', child2)
     self.assertEqual(child2['dataaa'], 'this is it')
     control = cfg.yaml_load_file(self.control_filename)
     self.assertEqual(data, control)
示例#5
0
 def test_import_from_string(self):
     import yaml
     util.set_config_base_dir(util.rel_to_file('import_test'), prefix=False)
     self.control_filename = util.rel_to_file(
         'import_test/control_text.yaml')
     data = yaml.load("""
                      nothing: 0
                      child1: !text_import
                          url: file://c1_text.yaml
                      """)
     control = cfg.yaml_load_file(self.control_filename)
     self.assertEqual(data, control)
示例#6
0
 def test_import_from_string(self):
     import yaml
     util.set_config_base_dir(util.rel_to_file('import_test'),
                              prefix=False)
     self.control_filename = util.rel_to_file('import_test/control_text.yaml')
     data = yaml.load("""
                      nothing: 0
                      child1: !text_import
                          url: file://c1_text.yaml
                      """)
     control = cfg.yaml_load_file(self.control_filename)
     self.assertEqual(data, control)
示例#7
0
 def auth_data(self, section_name, instance_data):
     filter_list = yaml_load_file(ib.configured_auth_data_path).get(section_name, None)
     if not filter_list:
         raise KeyError('Section \'{0:s}\' not found in auth_data specified in \'{1:s}\'!'.format(section_name,ib.configured_auth_data_path))
     selected_auth_data = []
     for filter in filter_list:
         auth_data = filter.pop('auth_data')
         if self.is_subdict(filter, instance_data):
             selected_auth_data.append(auth_data)
     if len(selected_auth_data) > 1:
         raise ValueError('Cannot determine authorization information: auth_data filters result more than one possible authorization section!')
     if len(selected_auth_data) < 1:
         raise ValueError('Cannot determine authorization information: auth_data filters result zero possible authorization section!')
     return selected_auth_data[0]
示例#8
0
 def auth_data(self, section_name, instance_data):
     filter_list = yaml_load_file(ib.configured_auth_data_path).get(
         section_name, None)
     if not filter_list:
         return None
     selected_auth_data = []
     for filter in filter_list:
         auth_data = filter.pop('auth_data')
         if self.is_subdict(filter, instance_data):
             selected_auth_data.append(auth_data)
     if len(selected_auth_data) > 1:
         raise ValueError(
             'Cannot determine authorization information: auth_data filters result more than one possible authorization section!'
         )
     if len(selected_auth_data) < 1:
         return None
     return selected_auth_data[0]
示例#9
0
 def test_python_import(self):
     import occo.exceptions as exc
     with self.assertRaises(exc.AutoImportError):
         config.yaml_load_file(util.rel_to_file('badmod.yaml'))
示例#10
0
 def test_python_import(self):
     import occo.exceptions as exc
     with self.assertRaises(exc.AutoImportError):
         config.yaml_load_file(util.rel_to_file('badmod.yaml'))