Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
commit c7ce8df8ca245a672cd49803a1a8a586ba9e36af Author: Bohuslav Kabrda bkabrda@redhat.com Date: Wed Nov 21 15:08:20 2012 +0100
Few more tests and a connected fix in a url route
wsgi/coprs/views/coprs_ns/coprs_general.py | 2 +- .../tests/test_views/test_coprs_ns/test_general.py | 27 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/wsgi/coprs/views/coprs_ns/coprs_general.py b/wsgi/coprs/views/coprs_ns/coprs_general.py index 077609e..a281019 100644 --- a/wsgi/coprs/views/coprs_ns/coprs_general.py +++ b/wsgi/coprs/views/coprs_ns/coprs_general.py @@ -123,7 +123,7 @@ def copr_update(username, coprname): return flask.render_template('coprs/edit.html', copr = copr, form = form)
-@coprs_ns.route('/detail/<username>/<coprname>/apply_for_building', methods = ['POST']) +@coprs_ns.route('/detail/<username>/<coprname>/apply_for_building/', methods = ['POST']) @login_required def copr_apply_for_building(username, coprname): copr = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname).first() diff --git a/wsgi/tests/test_views/test_coprs_ns/test_general.py b/wsgi/tests/test_views/test_coprs_ns/test_general.py index af8f06c..e5f6478 100644 --- a/wsgi/tests/test_views/test_coprs_ns/test_general.py +++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py @@ -128,6 +128,15 @@ class TestCoprDetail(CoprsTestCase): r = c.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c2.name)) assert '<input type=submit value="Apply for building">' in r.data
+ def test_copr_detail_doesnt_allow_owner_to_ask_for_building(self, f_users, f_coprs): + with self.tc as c: + with c.session_transaction() as s: + s['openid'] = self.u2.openid_name + + self.db.session.add_all([self.u2, self.c2]) + r = c.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c2.name)) + assert '<input type=submit value="Apply for building">' not in r.data + def test_copr_detail_allows_giving_up_building(self, f_users, f_coprs, f_copr_permissions): with self.tc as c: with c.session_transaction() as s: @@ -160,3 +169,21 @@ class TestCoprUpdate(CoprsTestCase): data = {'name': self.c1.name, 'release': self.c1.release, 'arches': self.c1.arches, 'id': self.c1.id}, follow_redirects = True) assert 'Copr was updated successfully' in r.data + +class TestCoprApplyForBuilding(CoprsTestCase): + def test_apply(self, f_users, f_coprs): + with self.tc as c: + with c.session_transaction() as s: + s['openid'] = self.u2.openid_name + + self.db.session.add_all([self.u1, self.u2, self.c1]) + r = c.post('/coprs/detail/{0}/{1}/apply_for_building/'.format(self.u1.name, self.c1.name), + follow_redirects = True) + print r.data + assert 'You have successfuly applied' in r.data + + self.db.session.add_all([self.u1, self.u2, self.c1]) + new_perm = self.models.CoprPermission.query.filter(self.models.CoprPermission.user_id == self.u2.id).\ + filter(self.models.CoprPermission.copr_id == self.c1.id).\ + first() + assert not new_perm.approved
copr-devel@lists.fedorahosted.org