Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHELC-967] Verify breadcrumbs source_os #1432

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions convert2rhel/breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,52 @@

def _set_activity(self):
"""Set the activity that convert2rhel is going to perform"""
self.activity = tool_opts.activity
try:
self.activity = tool_opts.activity
if not self.activity:
raise ValueError("Activity is not set in tool_opts")
except Exception as e:
print(f"Error setting activity: {e}")

Check warning on line 116 in convert2rhel/breadcrumbs.py

View check run for this annotation

Codecov / codecov/patch

convert2rhel/breadcrumbs.py#L114-L116

Added lines #L114 - L116 were not covered by tests

def _set_pkg_object(self):
"""Set pkg_object which is used to get information about installed Convert2RHEL"""
# the index position is there because get_installed_pkg_objects return list, which is filtered and
# should contain just one item
self._pkg_object = pkghandler.get_installed_pkg_objects(name="convert2rhel")[0]
try:
pkg_objects = pkghandler.get_installed_pkg_objects(name="convert2rhel")
if not pkg_objects:
raise ValueError("No installed package objects found for convert2rhel")

Check warning on line 123 in convert2rhel/breadcrumbs.py

View check run for this annotation

Codecov / codecov/patch

convert2rhel/breadcrumbs.py#L123

Added line #L123 was not covered by tests
self._pkg_object = pkg_objects[0]
except Exception as e:
print(f"Error setting pkg_object: {e}")

Check warning on line 126 in convert2rhel/breadcrumbs.py

View check run for this annotation

Codecov / codecov/patch

convert2rhel/breadcrumbs.py#L125-L126

Added lines #L125 - L126 were not covered by tests

def _set_executed(self):
"""Set how was Convert2RHEL executed"""
self.executed = " ".join(utils.hide_secrets(args=sys.argv))
try:
self.executed = " ".join(utils.hide_secrets(args=sys.argv))
if not self.executed:
raise ValueError("Executed command is not set")
except Exception as e:
print(f"Error setting executed: {e}")

Check warning on line 135 in convert2rhel/breadcrumbs.py

View check run for this annotation

Codecov / codecov/patch

convert2rhel/breadcrumbs.py#L133-L135

Added lines #L133 - L135 were not covered by tests

def _set_nevra(self):
"""Set NEVRA of installed Convert2RHEL"""
self.nevra = pkghandler.get_pkg_nevra(self._pkg_object, include_zero_epoch=True)
try:
self.nevra = pkghandler.get_pkg_nevra(self._pkg_object, include_zero_epoch=True)
if not self.nevra:
raise ValueError("NEVRA is not set")
except Exception as e:
print(f"Error setting nevra: {e}")

Check warning on line 144 in convert2rhel/breadcrumbs.py

View check run for this annotation

Codecov / codecov/patch

convert2rhel/breadcrumbs.py#L142-L144

Added lines #L142 - L144 were not covered by tests

def _set_signature(self):
"""Set signature of installed Convert2RHEL"""
package = pkghandler.get_installed_pkg_information(str(self._pkg_object))[0]
self.signature = package.signature
try:
package_info = pkghandler.get_installed_pkg_information(str(self._pkg_object))
if not package_info:
raise ValueError("No package information found for convert2rhel")

Check warning on line 151 in convert2rhel/breadcrumbs.py

View check run for this annotation

Codecov / codecov/patch

convert2rhel/breadcrumbs.py#L151

Added line #L151 was not covered by tests
self.signature = package_info[0].signature
if not self.signature:
raise ValueError("Signature is not set")
except Exception as e:
print(f"Error setting signature: {e}")

Check warning on line 156 in convert2rhel/breadcrumbs.py

View check run for this annotation

Codecov / codecov/patch

convert2rhel/breadcrumbs.py#L154-L156

Added lines #L154 - L156 were not covered by tests

def _set_started(self):
"""Set start time of activity"""
Expand Down
Loading