Skip to content

Commit

Permalink
change func
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeWang1127 committed Sep 30, 2024
1 parent 27d3904 commit 502b4cc
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions library_generation/test/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
from filecmp import dircmp
from git import Repo
import os
import shutil
import subprocess
import unittest
from shutil import copytree
from shutil import copyfile
from shutil import rmtree
from shutil import copy
from shutil import move
from pathlib import Path
from library_generation.model.generation_config import GenerationConfig
from library_generation.model.generation_config import from_yaml
Expand Down Expand Up @@ -187,7 +188,7 @@ def test_entry_point_running_in_container(self):
)
print(" PR description comparison succeed.")
self.__remove_generated_files()
shutil.rmtree(api_definitions_path)
rmtree(api_definitions_path)

@classmethod
def __copy_api_definition(cls, committish: str) -> str:
Expand All @@ -196,13 +197,9 @@ def __copy_api_definition(cls, committish: str) -> str:
)
api_temp_dir = tempfile.mkdtemp()
print(f"Copying api definition to {api_temp_dir}...")
shutil.copytree(
f"{repo_dest}/google", f"{api_temp_dir}/google", dirs_exist_ok=True
)
shutil.copytree(
f"{repo_dest}/grafeas", f"{api_temp_dir}/grafeas", dirs_exist_ok=True
)
shutil.rmtree(repo_dest)
copytree(f"{repo_dest}/google", f"{api_temp_dir}/google", dirs_exist_ok=True)
copytree(f"{repo_dest}/grafeas", f"{api_temp_dir}/grafeas", dirs_exist_ok=True)
rmtree(repo_dest)
return api_temp_dir

@classmethod
Expand Down Expand Up @@ -238,17 +235,17 @@ def __download_generator_jar(cls, coordinates_file: str) -> None:
destination_jar_path = os.path.join(
config_dir, WELL_KNOWN_GENERATOR_JAR_FILENAME
)
shutil.move(source_jar_path, destination_jar_path)
move(source_jar_path, destination_jar_path)

@classmethod
def __remove_generated_files(cls):
shutil.rmtree(f"{output_dir}", ignore_errors=True)
rmtree(f"{output_dir}", ignore_errors=True)
if os.path.isdir(f"{golden_dir}"):
shutil.rmtree(f"{golden_dir}")
rmtree(f"{golden_dir}")

@classmethod
def __pull_repo_to(cls, dest: Path, repo: str, committish: str) -> str:
shutil.rmtree(dest, ignore_errors=True)
rmtree(dest, ignore_errors=True)
repo_url = f"{repo_prefix}/{repo}"
print(f"Cloning repository {repo_url}")
repo = Repo.clone_from(repo_url, dest)
Expand All @@ -274,7 +271,7 @@ def __prepare_golden_files(
f"{repo_dest}/gapic-libraries-bom",
f"{golden_dir}/gapic-libraries-bom",
)
copyfile(f"{repo_dest}/pom.xml", golden_dir)
copy(f"{repo_dest}/pom.xml", golden_dir)
else:
copytree(f"{repo_dest}", f"{golden_dir}/{library_name}")

Expand Down

0 comments on commit 502b4cc

Please sign in to comment.