[copr] bkabrda-workspace: Few more tests and some fixes/alterations (d240462)

bkabrda at fedorahosted.org bkabrda at fedorahosted.org
Wed Nov 21 09:46:35 UTC 2012


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : bkabrda-workspace

>---------------------------------------------------------------

commit d240462c6477fb845eac5599dff5e59e22c7f2e8
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Wed Nov 21 10:46:22 2012 +0100

    Few more tests and some fixes/alterations


>---------------------------------------------------------------

 wsgi/tests/coprs_test_case.py                      |    6 +-
 .../tests/test_views/test_coprs_ns/test_general.py |   40 ++++++++++++++++++--
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/wsgi/tests/coprs_test_case.py b/wsgi/tests/coprs_test_case.py
index 0c679e5..ea4903e 100644
--- a/wsgi/tests/coprs_test_case.py
+++ b/wsgi/tests/coprs_test_case.py
@@ -59,9 +59,9 @@ class CoprsTestCase(object):
 
     @pytest.fixture
     def f_copr_permissions(self):
-        self.cp1 = models.CoprPermission(copr = self.c2, user = self.u2, approved = True)
+        self.cp1 = models.CoprPermission(copr = self.c2, user = self.u1, approved = True)
         self.cp2 = models.CoprPermission(copr = self.c3, user = self.u2, approved = False)
-        self.cp3 = models.CoprPermission(copr = self.c3, user = self.u1, approved = True)
+        self.cp3 = models.CoprPermission(copr = self.c3, user = self.u1, approved = False)
 
-        self.db.session.add_all([self.cp1, self.cp2])
+        self.db.session.add_all([self.cp1, self.cp2, self.cp3])
         self.db.session.commit()
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 1c58704..4ceb2f2 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -37,19 +37,21 @@ class TestCoprsAllowed(CoprsTestCase):
             assert 'No entries' in r.data
 
     def test_allowed_one(self, f_users, f_coprs, f_copr_permissions):
+        uname = self.u1.name
         with self.tc as c:
             with c.session_transaction() as s:
-                s['openid'] = self.u1.openid_name
+                s['openid'] = self.u2.openid_name
 
-            r = c.get('/coprs/allowed/{0}/'.format(self.u1.name))
+            r = c.get('/coprs/allowed/{0}/'.format(uname))
             assert r.data.count('<div class=copr>') == 1
 
     def test_allowed_one_but_asked_for_one_more(self, f_users, f_coprs, f_copr_permissions):
+        uname = self.u1.name
         with self.tc as c:
             with c.session_transaction() as s:
-                s['openid'] = self.u2.openid_name
+                s['openid'] = self.u1.openid_name
 
-            r = c.get('/coprs/allowed/{0}/'.format(self.u2.name))
+            r = c.get('/coprs/allowed/{0}/'.format(uname))
             assert r.data.count('<div class=copr>') == 1
 
 class TestCoprNew(CoprsTestCase):
@@ -101,3 +103,33 @@ class TestCoprDetail(CoprsTestCase):
     def test_copr_detail_contains_builds(self, f_users, f_coprs, f_builds):
         r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u1.name, self.c1.name))
         assert r.data.count('<tr class=build') == 2
+
+    def test_copr_detail_contains_permissions(self, f_users, f_coprs, f_copr_permissions):
+        r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c3.name))
+        assert '<table class=permissions' in r.data
+        assert '<tr><td>{0}'.format(self.u2.name) in r.data
+        assert '<tr><td>{0}'.format(self.u1.name) in r.data
+
+    def test_copr_detail_doesnt_contain_forms_for_anonymous_user(self, f_users, f_coprs):
+        r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c3.name))
+        assert '<form' not in r.data
+
+    def test_copr_detail_allows_asking_for_building(self, f_users, f_coprs):
+        uname = self.u2.name
+        cname = self.c2.name
+        with self.tc as c:
+            with c.session_transaction() as s:
+                s['openid'] = self.u1.openid_name
+
+            r = c.get('/coprs/detail/{0}/{1}/'.format(uname, cname))
+            assert '<input type=submit value="Apply for building">' in r.data
+
+    def test_copr_detail_allows_giving_up_building(self, f_users, f_coprs, f_copr_permissions):
+        uname = self.u2.name
+        cname = self.c2.name
+        with self.tc as c:
+            with c.session_transaction() as s:
+                s['openid'] = self.u1.openid_name
+
+            r = c.get('/coprs/detail/{0}/{1}/'.format(uname, cname))
+            assert '<input type=submit value="Give up building">' in r.data



More information about the copr-devel mailing list