Skip to content

Commit

Permalink
check_all_key_are_valid function test added
Browse files Browse the repository at this point in the history
Also fix typo here(unvalid => invalid)
  • Loading branch information
lennonwoo committed Jul 3, 2019
1 parent 263275f commit d2ef245
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bloom/generators/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ def _check_all_keys_are_valid(self, peer_packages, rosdistro):
all_keys_valid = False
return all_keys_valid

def _pre_modify(self, key_unvalid_error_msg):
def check_all_keys_are_valid(self, key_invalid_error_msg):
info("\nPre-verifying {0} dependency keys...".format(self.package_manager))
# Run rosdep update is needed
if not self.has_run_rosdep:
Expand All @@ -850,7 +850,7 @@ def _pre_modify(self, key_unvalid_error_msg):
peer_packages = [p.name for p in self.packages.values()]

while not self._check_all_keys_are_valid(peer_packages, self.rosdistro):
error(key_unvalid_error_msg)
error(key_invalid_error_msg)
try:
if not maybe_continue(msg="Would you like to try again?"):
error("User aborted after rosdep keys were not resolved.")
Expand Down
2 changes: 1 addition & 1 deletion bloom/generators/debian/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def pre_modify(self):
"Some of the dependencies for packages in this repository could not be resolved by rosdep.\n",
"You can try to address the issues which appear above and try again if you wish."
])
PackageManagerGenerator._pre_modify(self, error_msg)
PackageManagerGenerator.check_all_keys_are_valid(self, error_msg)

def generate_package(self, package, os_version):
info("Generating {0} for {1}...".format(self.package_manager, os_version))
Expand Down
2 changes: 1 addition & 1 deletion bloom/generators/rpm/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def pre_modify(self):
"You can try to address the issues which appear above and try again if you wish, ",
"or continue without releasing into RPM-based distributions (e.g. Fedora 24)."
])
PackageManagerGenerator._pre_modify(self, error_msg)
PackageManagerGenerator.check_all_keys_are_valid(self, error_msg)

for package in self.packages.values():
if not package.licenses or not package.licenses[0]:
Expand Down
16 changes: 16 additions & 0 deletions test/unit_tests/test_generators/test_common/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,19 @@ def dir_exist_default(data):
assert content == placed_files_dict[f]
for f in data.original_normal_files:
assert f in placed_files_dict.keys()


def test_bad_dependency():
bad_pkg_name = 'bad_dependency_pkg'
bad_pkg = get_package(bad_pkg_name)
pkg_bad_dict = {bad_pkg_name: bad_pkg}

gen = get_generator()
gen.packages = pkg_bad_dict
gen.rosdistro = 'kinetic'
gen.os_name = 'ubuntu'
gen.distros = ['xenial']
with bloom_answer(['n']):
with AssertRaisesContext(SystemExit, str(code.GENERATOR_NO_ROSDEP_KEY_FOR_DISTRO)):
with redirected_stdio():
gen.check_all_keys_are_valid("")

0 comments on commit d2ef245

Please sign in to comment.