Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeWang1127 committed May 3, 2024
1 parent 6a463d8 commit 6faf2db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
10 changes: 10 additions & 0 deletions library_generation/test/compare_poms.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ def compare_xml(expected, actual, print_trees):
return False


def compare_pom_in_subdir(base_dir: str, subdir: str) -> bool:
golden = os.path.join(base_dir, subdir, "pom-golden.xml")
pom = os.path.join(base_dir, subdir, "pom.xml")
return compare_xml(
golden,
pom,
False,
)


if __name__ == "__main__":
if len(sys.argv) != 4:
eprint(
Expand Down
18 changes: 3 additions & 15 deletions library_generation/test/owlbot/fix_poms_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
import shutil
import unittest
from library_generation.owlbot.src.fix_poms import main
from library_generation.test.compare_poms import compare_xml
from library_generation.test.test_utils import FileComparator
from library_generation.test.compare_poms import compare_pom_in_subdir

script_dir = os.path.dirname(os.path.realpath(__file__))
resources_dir = os.path.join(script_dir, "..", "resources", "test-owlbot")
file_comparator = FileComparator()


class FixPomsTest(unittest.TestCase):
def test_fix_poms_update_poms_for_ad_manager_correctly(self):
def test_update_poms_group_id_does_not_start_with_google_correctly(self):
ad_manager_resource = os.path.join(resources_dir, "java-admanager")
versions_file = os.path.join(ad_manager_resource, "versions.txt")
os.chdir(ad_manager_resource)
Expand All @@ -33,7 +31,7 @@ def test_fix_poms_update_poms_for_ad_manager_correctly(self):
self.__copy__golden(ad_manager_resource, sub_dir)
main(versions_file, "true")
for sub_dir in sub_dirs:
self.assertFalse(self.__compare_pom_in_subdir(ad_manager_resource, sub_dir))
self.assertFalse(compare_pom_in_subdir(ad_manager_resource, sub_dir))
for sub_dir in sub_dirs:
self.__remove_file_in_subdir(ad_manager_resource, sub_dir)

Expand All @@ -43,16 +41,6 @@ def __copy__golden(cls, base_dir: str, subdir: str):
pom = os.path.join(base_dir, subdir, "pom.xml")
shutil.copyfile(golden, pom)

@classmethod
def __compare_pom_in_subdir(cls, base_dir: str, subdir: str):
golden = os.path.join(base_dir, subdir, "pom-golden.xml")
pom = os.path.join(base_dir, subdir, "pom.xml")
return compare_xml(
golden,
pom,
False,
)

@classmethod
def __remove_file_in_subdir(cls, base_dir: str, subdir: str):
pom = os.path.join(base_dir, subdir, "pom.xml")
Expand Down

0 comments on commit 6faf2db

Please sign in to comment.