Skip to content

Commit

Permalink
Merge pull request #2609 from phillxnet/2426_update_use_of_python_dis…
Browse files Browse the repository at this point in the history
…tro_module_re_1.7.0+_changes

update use of python distro module re 1.7.0+ changes #2426
  • Loading branch information
phillxnet authored Jul 11, 2023
2 parents 0d81038 + b3da69e commit beecea6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ psutil = "==5.9.4"
# mock = "==1.0.1" now part of std lib in Python 3.3 onwards as unittest.mock
# pyzmq requires libzmq5 on system unless in wheel form.
pyzmq = "==19.0.2" # Last specifying Python 2 on PyPi page.
distro = "==1.6.0" # Last Python 2/3 version that works as we expect.
distro = "*"
URLObject = "==2.1.1"
# https://pypi.org/project/supervisor/ 4.1.0 onwards embeds unmaintained meld3
supervisor = "==4.2.4"
Expand Down
5 changes: 3 additions & 2 deletions src/rockstor/smart_manager/views/docker_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@

DOCKERD = "/usr/bin/dockerd"

# Distro's for which we have known working conf/docker-distroid.service files.
KNOWN_DISTRO_IDS = ["rockstor", "opensuse-leap", "opensuse-tumbleweed"]
# Distros for which we have had known working conf/docker-distroid.service files.
# This mechanism has now been superseded but is maintained just-in-case for now.
KNOWN_DISTRO_IDS = ["rockstor", "opensuse", "opensuse-tumbleweed"]


class DockerServiceView(BaseServiceDetailView):
Expand Down
18 changes: 10 additions & 8 deletions src/rockstor/system/tests/test_pkg_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@
class SystemPackageTests(unittest.TestCase):
"""
The tests in this suite can be run via the following command:
cd <root dir of rockstor ie /opt/rockstor-dev>
./bin/test --settings=test-settings -v 3 -p test_pkg_mgmt*
cd /opt/rockstor/src/rockstor
export DJANGO_SETTINGS_MODULE=settings
poetry run django-admin test -p test_pkg_mgmt.py -v 2
"""

def setUp(self):
self.patch_run_command = patch("system.pkg_mgmt.run_command")
self.mock_run_command = self.patch_run_command.start()

# We need to test the conditions of distro.id() returning one of:
# rockstor, opensuse-leap, opensuse-tumbleweed
# rockstor, opensuse, (was opensuse-leap), opensuse-tumbleweed
self.patch_distro = patch("system.pkg_mgmt.distro")
self.mock_distro = self.patch_distro.start()

Expand Down Expand Up @@ -106,15 +107,16 @@ def test_pkg_update_check(self):
yum check-update -q -x rock*
and:
output format of:
distro.id = "opensuse-leap"
distro.id = "opensuse" N.B. this was "opensuse-leap" in distro <= 1.6.0
zypper -q list-updates
and:
distro.id = "opensuse-tumbleweed"
same command as for opensuse-leap
same command as for "opensuse"
"""
# Mock pkg_changelog to allow for isolated testing of yum_check
self.patch_pkg_changelog = patch("system.pkg_mgmt.pkg_changelog")
self.mock_pkg_changelog = self.patch_pkg_changelog.start()
# TODO:

def fake_pkg_changelog(*args, **kwargs):
"""
Expand Down Expand Up @@ -265,7 +267,7 @@ def fake_pkg_changelog(*args, **kwargs):
]
)
rc.append(106)
dist_id.append("opensuse-leap")
dist_id.append("opensuse")
#
for o, e, r, expected, distro in zip(out, err, rc, expected_result, dist_id):
self.mock_run_command.return_value = (o, e, r)
Expand Down Expand Up @@ -382,7 +384,7 @@ def test_rpm_build_info(self):
rc = [0]
expected_results = [("3.9.2-50.2093", "2019-Nov-30")]
# Leap15.1 dnf-yum
dist_id.append("opensuse-leap")
dist_id.append("opensuse")
out.append(
[
"Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync", # noqa E501
Expand Down Expand Up @@ -594,7 +596,7 @@ def test_pkg_latest_available(self):
rc.append(1)
expected_result.append(None)
# Leap15.1 dnf-yum - rockstor package installed with update available:
dist_id.append("opensuse-leap")
dist_id.append("opensuse")
out.append(
[
"Last metadata expiration check: 0:00:10 ago on Mon 02 Dec 2019 06:22:10 PM GMT.",
Expand Down

0 comments on commit beecea6

Please sign in to comment.