python-glareclient: move to python3
Documentation is currently disable as upstream hasn't moved to openstackdocstheme yet. Included a patch for fixing failing tests on python3. (https://review.opendev.org/#/c/587628/) Change-Id: I1251eef1c5e5ed9e919b124c51a0e81226fa3532
This commit is contained in:
parent
6ac2391407
commit
7936a7224a
|
@ -0,0 +1,84 @@
|
|||
From b1364646f78cf9e24ca9f74a7af093d240c094c0 Mon Sep 17 00:00:00 2001
|
||||
From: Corey Bryant <corey.bryant@canonical.com>
|
||||
Date: Tue, 31 Jul 2018 17:10:20 -0400
|
||||
Subject: [PATCH] python3 compatibility for failing unit tests
|
||||
|
||||
Handle StopIteration for Py3.7. PEP 0479,
|
||||
https://www.python.org/dev/peps/pep-0479/, makes the following
|
||||
change: "when StopIteration is raised inside a generator, it is
|
||||
replaced it with RuntimeError". And states: "If raise StopIteration
|
||||
occurs directly in a generator, simply replace it with return."
|
||||
|
||||
Also fix test cases that make assumptions about the ordering of
|
||||
**kwargs. Python, up to 3.6, doesn't preserve any ordering for those.
|
||||
And the behavior differs between various Python versions.
|
||||
For details see PEP 0468 (https://www.python.org/dev/peps/pep-0468/)
|
||||
|
||||
Change-Id: I9847053534ffd47c4559d504be647be0de25b651
|
||||
Closes-Bug: #1784714
|
||||
Closes-Bug: #1711469
|
||||
---
|
||||
glareclient/tests/unit/v1/test_artifacts.py | 26 +++++++++++----------
|
||||
glareclient/v1/artifacts.py | 2 +-
|
||||
2 files changed, 15 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/glareclient/tests/unit/v1/test_artifacts.py b/glareclient/tests/unit/v1/test_artifacts.py
|
||||
index 2fd0450..41d4468 100644
|
||||
--- a/glareclient/tests/unit/v1/test_artifacts.py
|
||||
+++ b/glareclient/tests/unit/v1/test_artifacts.py
|
||||
@@ -50,17 +50,19 @@ class TestController(testtools.TestCase):
|
||||
body = self.c.update('test-id', type_name='test_name',
|
||||
remove_props=remove_props, update1=1, update2=2)
|
||||
self.assertEqual(self.mock_body, body)
|
||||
- patch_kwargs = {
|
||||
- 'headers': {'Content-Type': 'application/json-patch+json'},
|
||||
- 'json': [
|
||||
- {'path': '/remove1', 'value': None, 'op': 'replace'},
|
||||
- {'path': '/remove2', 'value': None, 'op': 'replace'},
|
||||
- {'path': '/update2', 'value': 2, 'op': 'add'},
|
||||
- {'path': '/update1', 'value': 1, 'op': 'add'}
|
||||
- ]
|
||||
- }
|
||||
- self.mock_http_client.patch.assert_called_once_with(
|
||||
- '/artifacts/checked_name/test-id', **patch_kwargs)
|
||||
+ headers = {'Content-Type': 'application/json-patch+json'}
|
||||
+ json = [
|
||||
+ {'path': '/remove1', 'value': None, 'op': 'replace'},
|
||||
+ {'path': '/remove2', 'value': None, 'op': 'replace'},
|
||||
+ {'path': '/update1', 'value': 1, 'op': 'add'},
|
||||
+ {'path': '/update2', 'value': 2, 'op': 'add'}
|
||||
+ ]
|
||||
+
|
||||
+ args, kwargs = self.mock_http_client.patch.call_args
|
||||
+ self.assertEqual(args, ('/artifacts/checked_name/test-id',))
|
||||
+ self.assertEqual(kwargs['headers'], headers)
|
||||
+ sorted_json = sorted(kwargs['json'], key=lambda k: k['path'])
|
||||
+ self.assertEqual(sorted_json, json)
|
||||
self.c._check_type_name.assert_called_once_with('test_name')
|
||||
|
||||
def test_get(self):
|
||||
@@ -169,7 +171,7 @@ class TestController(testtools.TestCase):
|
||||
schemas = {'schemas': {'a': {'version': 1}, 'b': {'version': 2}}}
|
||||
self.mock_http_client.get.return_value = (None, schemas)
|
||||
expected_types = [('a', 1), ('b', 2)]
|
||||
- self.assertEqual(expected_types, self.c.get_type_list())
|
||||
+ self.assertEqual(expected_types, sorted(self.c.get_type_list()))
|
||||
|
||||
def test_get_type_schema(self):
|
||||
test_schema = {'schemas': {'checked_name': 'test-schema'}}
|
||||
diff --git a/glareclient/v1/artifacts.py b/glareclient/v1/artifacts.py
|
||||
index bfe549b..cf55975 100644
|
||||
--- a/glareclient/v1/artifacts.py
|
||||
+++ b/glareclient/v1/artifacts.py
|
||||
@@ -171,7 +171,7 @@ class Controller(object):
|
||||
if limit:
|
||||
limit -= 1
|
||||
if limit <= 0:
|
||||
- raise StopIteration
|
||||
+ return
|
||||
|
||||
try:
|
||||
next_url = body['next']
|
||||
--
|
||||
2.23.0
|
||||
|
|
@ -1,80 +1,93 @@
|
|||
%global sname python-glareclient
|
||||
Name: {{ py2name('python-glareclient') }}
|
||||
Epoch: {{ epoch('python-glareclient') }}
|
||||
Version: 0.5.3
|
||||
Release: 0
|
||||
{% set pypi_name = 'python-glareclient' %}
|
||||
{% set upstream_version = upstream_version('0.5.3') %}
|
||||
{% set rpm_release = '1' %}
|
||||
{% set source = url_pypi() %}
|
||||
|
||||
# Tempoary disable docs. They currently don't build with python3
|
||||
# https://bugs.launchpad.net/python-glareclient/+bug/1843407
|
||||
# and don't contain much useful information anyways.
|
||||
%global with_doc 0
|
||||
Name: {{ py2name(py_versions='py3') }}
|
||||
Version: {{ py2rpmversion() }}
|
||||
Release: {{ py2rpmrelease() }}
|
||||
Epoch: {{ epoch(' {{ pypi_name }} ') }}
|
||||
Summary: Python API and CLI for OpenStack Glare
|
||||
License: {{ license('Apache-2.0') }}
|
||||
Group: Development/Languages/Python
|
||||
URL: https://launchpad.net/%{sname}
|
||||
Source0: https://files.pythonhosted.org/packages/source/p/%{sname}/%{sname}-%{version}.tar.gz
|
||||
URL: https://launchpad.net/{{ pypi_name }}
|
||||
Source0: {{ source }}
|
||||
Patch1: 0001-python3-compatibility-for-failing-unit-tests.patch
|
||||
BuildRequires: openstack-macros
|
||||
BuildRequires: {{ py2pkg('PyYAML') }}
|
||||
BuildRequires: {{ py2pkg('coverage') }}
|
||||
BuildRequires: python-devel
|
||||
BuildRequires: {{ py2pkg('fixtures') }}
|
||||
BuildRequires: {{ py2pkg('mock') }}
|
||||
BuildRequires: {{ py2pkg('os-client-config') }}
|
||||
BuildRequires: {{ py2pkg('osc-lib') }}
|
||||
BuildRequires: {{ py2pkg('oslo.log') }}
|
||||
BuildRequires: {{ py2pkg('oslo.utils') }}
|
||||
BuildRequires: {{ py2pkg('reno') }}
|
||||
BuildRequires: {{ py2pkg('requests-mock') }}
|
||||
BuildRequires: {{ py2pkg('testrepository') }}
|
||||
BuildRequires: {{ py2pkg('testscenarios') }}
|
||||
BuildRequires: {{ py2pkg('testtools') }}
|
||||
Requires: {{ py2pkg('Babel') }}
|
||||
Requires: {{ py2pkg('PrettyTable') }}
|
||||
Requires: {{ py2pkg('keystoneauth1') }}
|
||||
Requires: {{ py2pkg('osc-lib') }}
|
||||
Requires: {{ py2pkg('oslo.i18n') }}
|
||||
Requires: {{ py2pkg('oslo.log') }}
|
||||
Requires: {{ py2pkg('oslo.utils') }}
|
||||
Requires: {{ py2pkg('pbr') }}
|
||||
Requires: {{ py2pkg('requests') }}
|
||||
Requires: {{ py2pkg('six') }}
|
||||
BuildRequires: {{ py3('PyYAML') }}
|
||||
BuildRequires: {{ py3('coverage') }}
|
||||
BuildRequires: {{ py3('fixtures') }}
|
||||
BuildRequires: {{ py3('mock') }}
|
||||
BuildRequires: {{ py3('os-client-config') }}
|
||||
BuildRequires: {{ py3('osc-lib') }}
|
||||
BuildRequires: {{ py3('oslo.log') }}
|
||||
BuildRequires: {{ py3('oslo.utils') }}
|
||||
BuildRequires: {{ py3('reno') }}
|
||||
BuildRequires: {{ py3('requests-mock') }}
|
||||
BuildRequires: {{ py3('testrepository') }}
|
||||
BuildRequires: {{ py3('testscenarios') }}
|
||||
Requires: {{ py3('Babel') }}
|
||||
Requires: {{ py3('PrettyTable') }}
|
||||
Requires: {{ py3('keystoneauth1') }}
|
||||
Requires: {{ py3('osc-lib') }}
|
||||
Requires: {{ py3('oslo.i18n') }}
|
||||
Requires: {{ py3('oslo.log') }}
|
||||
Requires: {{ py3('oslo.utils') }}
|
||||
Requires: {{ py3('pbr') }}
|
||||
Requires: {{ py3('requests') }}
|
||||
Requires: {{ py3('six') }}
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
Python bindings to the Glare Artifact Repository
|
||||
|
||||
%if 0%{?with_doc}
|
||||
%package doc
|
||||
Summary: Documentation for OpenStack Glare API Client
|
||||
Group: Documentation/HTML
|
||||
BuildRequires: {{ py2pkg('Sphinx') }}
|
||||
BuildRequires: {{ py2pkg('oslosphinx') }}
|
||||
BuildRequires: {{ py3('Sphinx') }}
|
||||
BuildRequires: {{ py3('openstackdocstheme') }}
|
||||
|
||||
%description doc
|
||||
Python bindings to the Glare Artifact Repository
|
||||
This package contains auto-generated documentation.
|
||||
%endif
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -n %{sname}-%{version}
|
||||
%autosetup -p1 -n {{ pypi_name }}-%{version}
|
||||
%py_req_cleanup
|
||||
|
||||
%build
|
||||
%py2_build
|
||||
%py3_build
|
||||
|
||||
# generate html docs
|
||||
%{__python2} setup.py build_sphinx
|
||||
# remove the sphinx-build leftovers
|
||||
rm -rf doc/build/html/.{doctrees,buildinfo}
|
||||
%if 0%{?with_doc}
|
||||
## generate html docs
|
||||
#PYTHONPATH=. PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
|
||||
## remove the sphinx-build leftovers
|
||||
#rm -rf doc/build/html/.{doctrees,buildinfo}
|
||||
%endif
|
||||
|
||||
%install
|
||||
%py2_install
|
||||
%py3_install
|
||||
|
||||
%check
|
||||
%{__python2} setup.py testr
|
||||
PYTHON=%{__python3} PYTHONPATH=. %{__python3} setup.py testr
|
||||
|
||||
%files
|
||||
%license LICENSE
|
||||
%doc README.rst ChangeLog
|
||||
%{_bindir}/glare
|
||||
%{python2_sitelib}/glareclient
|
||||
%{python2_sitelib}/*.egg-info
|
||||
%{python3_sitelib}/glareclient
|
||||
%{python3_sitelib}/*.egg-info
|
||||
|
||||
%if 0%{?with_doc}
|
||||
%files doc
|
||||
%license LICENSE
|
||||
%doc doc/build/html
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
|
|
Loading…
Reference in New Issue