Exemple #1
0
 def test_yaml_file_load_and_dump_roundtrip(self):
     input_content = "answer: #comment\n  is: '42'\n"  # comment should be preserved
     input_path = self._create_file(input_content)
     yaml = yaml_file_load(input_path)
     output_path = self._create_tmp_file_path()
     yaml_file_dump(yaml, output_path)
     output_content = self._read_file(output_path)
     self.assertEqual(output_content, input_content)
Exemple #2
0
 def __create_preview_info_file(self, gitops_config: GitOpsConfig) -> None:
     preview_id = self.__args.preview_id
     yaml_file_dump(
         {
             "previewId": preview_id,
             "previewIdHash":
             gitops_config.create_preview_id_hash(preview_id),
             "routeHost": gitops_config.get_preview_host(preview_id),
             "namespace": gitops_config.get_preview_namespace(preview_id),
         },
         "/tmp/gitopscli-preview-info.yaml",
     )
Exemple #3
0
 def test_yaml_file_dump_unknown_directory(self):
     try:
         yaml_file_dump({"answer": {"is": "42"}}, "/unknown-dir/foo")
         self.fail()
     except FileNotFoundError:
         pass
Exemple #4
0
 def test_yaml_file_dump(self):
     path = self._create_tmp_file_path()
     yaml_file_dump({"answer": {"is": "42"}}, path)
     yaml_content = self._read_file(path)
     self.assertEqual(yaml_content, "answer:\n  is: '42'\n")