Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit 32c392cbfecf6574910d948132ae831ff3ec3713
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Aug 26 13:38:14 2015 +0200
[frontend][api] require marshmallow >= 2; minor test update
---------------------------------------------------------------
frontend/copr-frontend.spec | 4 ++--
.../coprs/rest_api/resources/project_chroot.py | 5 +++--
frontend/coprs_frontend/coprs/rest_api/util.py | 4 ++--
.../tests/test_api/test_project_chroot.py | 9 +++++++++
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/frontend/copr-frontend.spec b/frontend/copr-frontend.spec
index def204d..4a6b670 100644
--- a/frontend/copr-frontend.spec
+++ b/frontend/copr-frontend.spec
@@ -54,7 +54,7 @@ Requires: pytz
Requires: python-six
Requires: python-netaddr
Requires: python-flask-restful
-Requires: python-marshmallow
+Requires: python-marshmallow >= 2.0.0
# for tests:
Requires: pytest
Requires: python-flexmock
@@ -88,7 +88,7 @@ BuildRequires: python-decorator
BuildRequires: python-markdown
BuildRequires: pytz
BuildRequires: python-flask-restful
-BuildRequires: python-marshmallow
+BuildRequires: python-marshmallow >= 2.0.0
%description
COPR is lightweight build system. It allows you to create new project in WebUI,
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/project_chroot.py
b/frontend/coprs_frontend/coprs/rest_api/resources/project_chroot.py
index 8958b96..6e03ee1 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/project_chroot.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/project_chroot.py
@@ -1,6 +1,9 @@
# coding: utf-8
import json
+import logging
+log = logging.getLogger(__name__)
+
import flask
from flask import url_for, make_response
from flask_restful import Resource, reqparse
@@ -121,8 +124,6 @@ class ProjectChrootR(Resource):
chroot = self._get_chroot_safe(copr, name)
chroot_data = mm_deserialize(CoprChrootSchema(), flask.request.data)
- if "name" in chroot_data.data:
- chroot_data.data.pop("name") # todo: why it's here? bug in
marshmallow?
try:
updated_chroot = CoprChrootsLogic.update_chroot(
user=flask.g.user,
diff --git a/frontend/coprs_frontend/coprs/rest_api/util.py
b/frontend/coprs_frontend/coprs/rest_api/util.py
index c74b2cb..a7e77b6 100644
--- a/frontend/coprs_frontend/coprs/rest_api/util.py
+++ b/frontend/coprs_frontend/coprs/rest_api/util.py
@@ -34,8 +34,8 @@ def json_loads_safe(raw, data_on_error=None):
"Failed to deserialize json string")
-def mm_deserialize(schema, obj_dict):
- result = schema.loads(obj_dict)
+def mm_deserialize(schema, json_string):
+ result = schema.loads(json_string)
if result.errors:
raise MalformedRequest(data="Failed to parse request: {}"
.format(result.errors))
diff --git a/frontend/coprs_frontend/tests/test_api/test_project_chroot.py
b/frontend/coprs_frontend/tests/test_api/test_project_chroot.py
index d28b892..3f84822 100644
--- a/frontend/coprs_frontend/tests/test_api/test_project_chroot.py
+++ b/frontend/coprs_frontend/tests/test_api/test_project_chroot.py
@@ -103,6 +103,15 @@ class TestProjectChrootResource(CoprsTestCase):
assert r3.status_code == 200
assert_content(json.loads(r3.data)["chroot"])
+ # test put with excessive name field
+ data["name"] = chroot_name
+ r4 = self.request_rest_api_with_auth(
+ "/api_2/projects/1/chroots/{}".format(chroot_name),
+ method="put",
+ content=data
+ )
+ assert r4.status_code == 200
+
def test_put_erasing(self, f_users, f_coprs, f_db, f_users_api, f_mock_chroots):
chroot_name = self.mc1.name
self.db.session.commit()