def test_parse_for_variable_hierarchies(self): data = 'testStr' keyword = 'Key' self.assertEqual(data, parse_for_variable_hierarchies(data, keyword)) data = CommentedSeq() data.insert(0, 'First') data.insert(1, 'Second') data.insert(2, 'Third') data.insert(3, 'Key') self.assertEqual('Key', parse_for_variable_hierarchies(data, keyword)) data = CommentedMap() data.insert(0, 'First', 'test1') data.insert(1, 'Second', 'test2') data.insert(2, 'Third', 'test3') data.insert(3, 'Key', 'test4') self.assertEqual('test4', parse_for_variable_hierarchies(data, keyword))
def test_datatype_is_CommentedMap(self): c = CommentedMap() c.insert(0, "key", "value") c.insert(1, "__from__", "test") self.assertEqual("test", parse_for_variable_hierarchies(c, "__from__")) c1 = CommentedMap() c1.insert(0, "key", "value") c2 = CommentedMap() c2.insert(0, "to", "from") c2.insert(1, "__from__", "to") c1.insert(2, "someseq", c2) result = CommentedMap() result.insert(0, "key", "value") result.insert(1, "someseq", "to") self.assertEqual(result, parse_for_variable_hierarchies(c1, "__from__"))
def phase_6(phase_5_output_file, yaml): phase_5_output = open(phase_5_output_file.name, 'r') input_data = yaml.load(phase_5_output) phase_6_output_file = open("./.temp/phase_6_output.yaml", 'w') #pass 1 variable_hierarchies = lexemes.parse_for_variable_hierarchies( input_data, "__from__") #pass 2 split_config = yaml_augmentation.split_component_config( variable_hierarchies) #pass 3 with_ids = yaml_augmentation.add_component_ids(split_config) print with_ids yaml.dump(with_ids, phase_6_output_file) return phase_6_output_file
def test_datatype_is_CommentedSeq(self): c = CommentedSeq() c.insert(0, "key") c.insert(1, "to") c2 = CommentedMap() c2.insert(0, "to", "from") c2.insert(1, "__from__", "to") c.insert(2, c2) result = CommentedSeq() result.append("key") result.append("to") result.append("to") self.assertEqual(result, parse_for_variable_hierarchies(c, "__from__"))
def phase_6(phase_5_output_file, yaml): phase_5_output = open(phase_5_output_file.name, 'r') input_data = yaml.load(phase_5_output) phase_6_output_file = open( os.path.join(tempfile.gettempdir(), "phase_6_output.yaml"), 'w') #pass 1 variable_hierarchies = lexemes.parse_for_variable_hierarchies( input_data, "__from__") #pass 2 split_config = yaml_augmentation.split_component_config( variable_hierarchies) #pass 3 container_split_config = yaml_augmentation.split_container_config( variable_hierarchies) #pass 4 with_ids = yaml_augmentation.add_execution_ids(container_split_config) print with_ids yaml.dump(with_ids, phase_6_output_file) return phase_6_output_file
def test_data_type_neither_CommentedSeq_nor_CommentedMap(self): data = dict({}) self.assertEqual(data, parse_for_variable_hierarchies(data, "__from__"))