Skip to content

Commit

Permalink
Fixups and Python 3.11 Environment
Browse files Browse the repository at this point in the history
Fixups:
 - Remove debug output
 - Cleanup format strings in ClusterManager class

Tox:
 - Add Python 3.11 environment
 - Drop Python 3.6 environment

Revert change to two assignment expressions. Without the need to further
support Python 3.6 assignment expressions can be used in conditionals,
i.e. `if (cs := data.get(...)):`.

Signed-off-by: Moritz Röhrich <moritz.rohrich@suse.com>
  • Loading branch information
m-ildefons authored and khushboo-rancher committed Nov 13, 2024
1 parent 48291a3 commit 5038deb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
4 changes: 0 additions & 4 deletions apiclient/rancher_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,21 @@ def __repr__(self):
def _get(self, path, **kwargs):
url = urljoin(self.endpoint, path)
resp = self.session.get(url, **kwargs)
print(f"{resp.request.method} {resp.request.url}")
return resp

def _post(self, path, **kwargs):
url = urljoin(self.endpoint, path)
resp = self.session.post(url, **kwargs)
print(f"{resp.request.method} {resp.request.url}")
return resp

def _put(self, path, **kwargs):
url = urljoin(self.endpoint, path)
resp = self.session.put(url, **kwargs)
print(f"{resp.request.method} {resp.request.url}")
return resp

def _delete(self, path, **kwargs):
url = urljoin(self.endpoint, path)
resp = self.session.delete(url, **kwargs)
print(f"{resp.request.method} {resp.request.url}")
return resp

def authenticate(self, user, passwd, **kwargs):
Expand Down
7 changes: 5 additions & 2 deletions apiclient/rancher_api/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,11 @@ def delete(self, name, *, raw=False):
return self._delete(self.PATH_fmt.format(uid=name), raw=raw)

def generate_kubeconfig(self, name, *, raw=False):
params = {'action': 'generateKubeconfig'}
return self._create(f"v3/clusters/{name}", raw=raw, params=params)
return self._create(
self.PATH1_fmt.format(uid=name),
raw=raw,
params={'action': 'generateKubeconfig'}
)

def explore(self, name):
from .cluster_api import ClusterExploreAPI # circular dependency
Expand Down
3 changes: 1 addition & 2 deletions harvester_e2e_tests/fixtures/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def __init__(self):
def _storage_net_configured(self):
code, data = self.settings.get('storage-network')

cs = data.get('status', {}).get('conditions')
if cs:
if (cs := data.get('status', {}).get('conditions')):
if 'True' == cs[-1].get('status') and 'Completed' == cs[-1].get('reason'):
return True, (code, data)
return False, (code, data)
Expand Down
3 changes: 1 addition & 2 deletions harvester_e2e_tests/integrations/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,7 @@ def test_degraded_volume(self, api_client, wait_timeout, vm_shell_from_host,
# https://github.com/harvester/harvester/issues/6425
code, data = api_client.hosts.get()
assert 200 == code, (code, data)
cluster_size = len(data['data'])
if cluster_size < 3:
if (cluster_size := len(data['data'])) < 3:
pytest.skip(
f"Degraded volumes only checked on 3+ nodes cluster, skip on {cluster_size}."
)
Expand Down
2 changes: 0 additions & 2 deletions py36_pytest.ini

This file was deleted.

9 changes: 4 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36,py38,pep8,testenv
envlist = py38,py311,pep8,testenv
# TODO(gyee): we are not distributing the test code right now. Will need
# to revisit this once we have majority of the tests developed.
skipsdist = True
Expand All @@ -20,6 +20,9 @@ commands =
pytest -c {env:PYTEST_CONFIG:{toxinidir}/tox.ini} {posargs}
passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY,PBR_VERSION

[testenv:py311]
basepython = python3.11

[testenv:pep8]
deps = flake8
commands =
Expand All @@ -31,7 +34,3 @@ max-line-length = 99
[pytest]
initial_sort = original
render_collapsed = all

[testenv:py36]
setenv =
PYTEST_CONFIG = {toxinidir}/py36_pytest.ini

0 comments on commit 5038deb

Please sign in to comment.