Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : frontend-python3
---------------------------------------------------------------
commit cea2c3532e4613c3aae1c60c127caa0290f94cbc
Author: Jakub Kadlčík <jkadlcik(a)redhat.com>
Date: Wed Sep 30 12:32:15 2015 +0200
[frontend] more py2/py3 compatibile strings magic
---------------------------------------------------------------
frontend/coprs_frontend/coprs/models.py | 2 +-
frontend/coprs_frontend/coprs/rest_api/common.py | 2 +-
frontend/coprs_frontend/coprs/rest_api/schemas.py | 3 ++-
.../tests/test_api/test_project_chroot_r.py | 4 ++--
.../test_views/test_coprs_ns/test_coprs_general.py | 2 +-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/models.py
b/frontend/coprs_frontend/coprs/models.py
index 63ef2bd..5f04a6e 100644
--- a/frontend/coprs_frontend/coprs/models.py
+++ b/frontend/coprs_frontend/coprs/models.py
@@ -646,7 +646,7 @@ class CoprChroot(db.Model, helpers.Serializer):
comps_name = db.Column(db.String(127), nullable=True)
def update_comps(self, comps_xml):
- self.comps_zlib = zlib.compress(comps_xml)
+ self.comps_zlib = zlib.compress(comps_xml.encode("utf-8"))
@property
def buildroot_pkgs_list(self):
diff --git a/frontend/coprs_frontend/coprs/rest_api/common.py
b/frontend/coprs_frontend/coprs/rest_api/common.py
index 6be90b2..d554369 100644
--- a/frontend/coprs_frontend/coprs/rest_api/common.py
+++ b/frontend/coprs_frontend/coprs/rest_api/common.py
@@ -91,7 +91,7 @@ def rest_api_auth_required(f):
base64string = flask.request.headers["Authorization"]
base64string = base64string.split()[1].strip()
userstring = base64.b64decode(base64string)
- (api_login, token) = userstring.split(b":")
+ (api_login, token) =
userstring.decode("utf-8").split(":")
except Exception:
log.exception("Failed to get auth token from headers")
api_login = token = None
diff --git a/frontend/coprs_frontend/coprs/rest_api/schemas.py
b/frontend/coprs_frontend/coprs/rest_api/schemas.py
index 2144b54..05cc5be 100644
--- a/frontend/coprs_frontend/coprs/rest_api/schemas.py
+++ b/frontend/coprs_frontend/coprs/rest_api/schemas.py
@@ -3,6 +3,7 @@
from collections import Iterable
from marshmallow import Schema, fields
from marshmallow import Schema, fields, validates_schema, ValidationError, validate
+from six import string_types
def validate_any(fn_list):
@@ -37,7 +38,7 @@ class SpaceSeparatedList(fields.Field):
def _deserialize(self, value):
if value is None:
return ""
- elif not isinstance(value, Iterable) or isinstance(value, basestring):
+ elif not isinstance(value, Iterable) or isinstance(value, string_types):
raise ValidationError("Value `{}` is not a list of strings"
.format(value))
else:
diff --git a/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
b/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
index 054b37f..0562737 100644
--- a/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
+++ b/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
@@ -93,7 +93,7 @@ class TestProjectChrootResource(CoprsTestCase):
for k, v in data.items():
assert response_data.get(k) == v
- assert_content(json.loads(r2.data)["chroot"])
+
assert_content(json.loads(r2.data.decode("utf-8"))["chroot"])
# test idempotency
self.request_rest_api_with_auth(
@@ -103,7 +103,7 @@ class TestProjectChrootResource(CoprsTestCase):
)
r3 = self.tc.get("/api_2/projects/1/chroots/{}".format(chroot_name))
assert r3.status_code == 200
- assert_content(json.loads(r3.data)["chroot"])
+
assert_content(json.loads(r3.data.decode("utf-8"))["chroot"])
# test put with excessive name field
data["name"] = chroot_name
diff --git a/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
b/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
index e34e971..64c6bb2 100644
--- a/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
+++ b/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
@@ -501,7 +501,7 @@ class TestCoprUpdatePermissions(CoprsTestCase):
'<option selected value="2">approved</option>'
'</select>'
)
- assert check_string not in r.data
+ assert check_string.encode("utf-8") not in r.data
@TransactionDecorator("u2")
def test_update_more_permissions(self, f_users, f_coprs,