[copr] bkabrda-workspace: Few more tests and some fixes/alterations (d240462)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit d240462c6477fb845eac5599dff5e59e22c7f2e8
Author: Bohuslav Kabrda <bkabrda(a)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
11 years, 5 months
[copr] bkabrda-workspace: More pythonic way of checking for substrin presence :) (aaafb07)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit aaafb0797a18fd8779c333e85f370dc11a09a3c2
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 21 09:52:19 2012 +0100
More pythonic way of checking for substrin presence :)
>---------------------------------------------------------------
.../tests/test_views/test_coprs_ns/test_general.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
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 55cfe3e..1c58704 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -17,7 +17,7 @@ class TestCoprsOwned(CoprsTestCase):
s['openid'] = self.u3.openid_name
r = c.get('/coprs/owned/{0}/'.format(self.u3.name))
- assert r.data.find('No entries') != -1
+ assert 'No entries' in r.data
def test_owned_one(self, f_users, f_coprs):
with self.tc as c:
@@ -34,7 +34,7 @@ class TestCoprsAllowed(CoprsTestCase):
s['openid'] = self.u3.openid_name
r = c.get('/coprs/allowed/{0}/'.format(self.u3.name))
- assert r.data.find('No entries') != -1
+ assert 'No entries' in r.data
def test_allowed_one(self, f_users, f_coprs, f_copr_permissions):
with self.tc as c:
@@ -96,7 +96,7 @@ class TestCoprDetail(CoprsTestCase):
def test_copr_detail_normal(self, f_users, f_coprs):
r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u1.name, self.c1.name))
assert r.status_code == 200
- assert r.data.find(self.c1.name) != -1
+ assert self.c1.name in r.data
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))
11 years, 5 months
[copr] bkabrda-workspace: Make the tests more adaptable to possible changes in fixtures (b174ef1)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit b174ef1a294dae1a9b97bbe1915cc4cad7740950
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 21 09:37:05 2012 +0100
Make the tests more adaptable to possible changes in fixtures
>---------------------------------------------------------------
.../tests/test_views/test_coprs_ns/test_general.py | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
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 f995b7c..55cfe3e 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -63,27 +63,29 @@ class TestCoprNew(CoprsTestCase):
assert "New entry was successfully posted" in r.data
def test_copr_new_exists_for_another_user(self, f_users, f_coprs):
+ name = self.c1.name
with self.tc as c:
with c.session_transaction() as s:
s['openid'] = self.u3.openid_name
- foocoprs = len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all())
+ foocoprs = len(self.models.Copr.query.filter(self.models.Copr.name == name).all())
assert foocoprs > 0
- r = c.post('/coprs/new/', data = {'name': 'foocopr', 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
- assert len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all()) == foocoprs + 1
+ r = c.post('/coprs/new/', data = {'name': name, 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
+ assert len(self.models.Copr.query.filter(self.models.Copr.name == name).all()) == foocoprs + 1
assert "New entry was successfully posted" in r.data
def test_copr_new_exists_for_this_user(self, f_users, f_coprs):
+ name = self.c1.name
with self.tc as c:
with c.session_transaction() as s:
s['openid'] = self.u1.openid_name
- foocoprs = len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all())
+ foocoprs = len(self.models.Copr.query.filter(self.models.Copr.name == name).all())
assert foocoprs > 0
- r = c.post('/coprs/new/', data = {'name': 'foocopr', 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
- assert len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all()) == foocoprs
+ r = c.post('/coprs/new/', data = {'name': name, 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
+ assert len(self.models.Copr.query.filter(self.models.Copr.name == name).all()) == foocoprs
assert "You already have copr named" in r.data
class TestCoprDetail(CoprsTestCase):
11 years, 5 months
[copr] bkabrda-workspace: Some tests for the copr detail (b2b2415)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit b2b2415a44dfc6428cf9638070afa64729351156
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 21 09:13:39 2012 +0100
Some tests for the copr detail
>---------------------------------------------------------------
.../tests/test_views/test_coprs_ns/test_general.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
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 c42b097..f995b7c 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -85,3 +85,17 @@ class TestCoprNew(CoprsTestCase):
r = c.post('/coprs/new/', data = {'name': 'foocopr', 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
assert len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all()) == foocoprs
assert "You already have copr named" in r.data
+
+class TestCoprDetail(CoprsTestCase):
+ def test_copr_detail_not_found(self):
+ r = self.tc.get('/coprs/detail/foo/bar/')
+ assert r.status_code == 404
+
+ def test_copr_detail_normal(self, f_users, f_coprs):
+ r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u1.name, self.c1.name))
+ assert r.status_code == 200
+ assert r.data.find(self.c1.name) != -1
+
+ 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
11 years, 5 months
[copr] bkabrda-workspace: Test adding new copr (a23368b)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit a23368b8f3e3a2858441d6dc024c5d06403926b4
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 21 08:56:58 2012 +0100
Test adding new copr
>---------------------------------------------------------------
.../tests/test_views/test_coprs_ns/test_general.py | 34 ++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
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 c350c07..c42b097 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -51,3 +51,37 @@ class TestCoprsAllowed(CoprsTestCase):
r = c.get('/coprs/allowed/{0}/'.format(self.u2.name))
assert r.data.count('<div class=copr>') == 1
+
+class TestCoprNew(CoprsTestCase):
+ def test_copr_new_normal(self, f_users):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u1.openid_name
+
+ r = c.post('/coprs/new/', data = {'name': 'foo', 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
+ assert self.models.Copr.query.filter(self.models.Copr.name == 'foo').first()
+ assert "New entry was successfully posted" in r.data
+
+ def test_copr_new_exists_for_another_user(self, f_users, f_coprs):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u3.openid_name
+
+ foocoprs = len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all())
+ assert foocoprs > 0
+
+ r = c.post('/coprs/new/', data = {'name': 'foocopr', 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
+ assert len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all()) == foocoprs + 1
+ assert "New entry was successfully posted" in r.data
+
+ def test_copr_new_exists_for_this_user(self, f_users, f_coprs):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u1.openid_name
+
+ foocoprs = len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all())
+ assert foocoprs > 0
+
+ r = c.post('/coprs/new/', data = {'name': 'foocopr', 'release': 'fedora-rawhide', 'arches': ['i386']}, follow_redirects = True)
+ assert len(self.models.Copr.query.filter(self.models.Copr.name == 'foocopr').all()) == foocoprs
+ assert "You already have copr named" in r.data
11 years, 5 months
[copr] bkabrda-workspace: Few changes to be able to test forms (no csrf, test modules can't import anything from coprs, as that instantiates new app outside of test env (ff3b1f5)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit ff3b1f51cd33a38a6ef6fc24c450bd165dbee6e4
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 21 08:48:59 2012 +0100
Few changes to be able to test forms (no csrf, test modules can't import anything from coprs, as that instantiates new app outside of test env
>---------------------------------------------------------------
wsgi/coprs/config.py | 1 +
wsgi/tests/coprs_test_case.py | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/wsgi/coprs/config.py b/wsgi/coprs/config.py
index e07f5d3..7dde9d7 100644
--- a/wsgi/coprs/config.py
+++ b/wsgi/coprs/config.py
@@ -25,6 +25,7 @@ class DevelopmentConfig(Config):
SQLALCHEMY_ECHO = True
class UnitTestConfig(Config):
+ CSRF_ENABLED = False
DATABASE = os.path.abspath('tests/data/copr.db')
OPENID_STORE = os.path.abspath('tests/data/openid_store')
diff --git a/wsgi/tests/coprs_test_case.py b/wsgi/tests/coprs_test_case.py
index 45b5572..0c679e5 100644
--- a/wsgi/tests/coprs_test_case.py
+++ b/wsgi/tests/coprs_test_case.py
@@ -11,8 +11,9 @@ class CoprsTestCase(object):
def setup_method(self, method):
self.tc = coprs.app.test_client()
self.app = coprs.app
+ self.app.testing = True
self.db = coprs.db
-
+ self.models = models
# create datadir if it doesn't exist
datadir = os.path.commonprefix([self.app.config['DATABASE'], self.app.config['OPENID_STORE']])
if not os.path.exists(datadir):
11 years, 5 months
[copr] bkabrda-workspace: More test cases (04e9f59)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 04e9f59af1652dab6d6c4c7153d4abb0d945e1f8
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 20 15:16:02 2012 +0100
More test cases
>---------------------------------------------------------------
wsgi/tests/coprs_test_case.py | 1 +
.../tests/test_views/test_coprs_ns/test_general.py | 26 ++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/wsgi/tests/coprs_test_case.py b/wsgi/tests/coprs_test_case.py
index 9b60e63..45b5572 100644
--- a/wsgi/tests/coprs_test_case.py
+++ b/wsgi/tests/coprs_test_case.py
@@ -60,6 +60,7 @@ class CoprsTestCase(object):
def f_copr_permissions(self):
self.cp1 = models.CoprPermission(copr = self.c2, user = self.u2, 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.db.session.add_all([self.cp1, self.cp2])
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 2174cb7..c350c07 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -10,6 +10,7 @@ class TestCoprsShow(CoprsTestCase):
r = self.tc.get('/')
assert r.data.count('<div class=copr>') == 3
+class TestCoprsOwned(CoprsTestCase):
def test_owned_none(self, f_users, f_coprs):
with self.tc as c:
with c.session_transaction() as s:
@@ -25,3 +26,28 @@ class TestCoprsShow(CoprsTestCase):
r = c.get('/coprs/owned/{0}/'.format(self.u1.name))
assert r.data.count('<div class=copr>') == 1
+
+class TestCoprsAllowed(CoprsTestCase):
+ def test_allowed_none(self, f_users, f_coprs, f_copr_permissions):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u3.openid_name
+
+ r = c.get('/coprs/allowed/{0}/'.format(self.u3.name))
+ assert r.data.find('No entries') != -1
+
+ def test_allowed_one(self, f_users, f_coprs, f_copr_permissions):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u1.openid_name
+
+ r = c.get('/coprs/allowed/{0}/'.format(self.u1.name))
+ 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):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u2.openid_name
+
+ r = c.get('/coprs/allowed/{0}/'.format(self.u2.name))
+ assert r.data.count('<div class=copr>') == 1
11 years, 5 months
[copr] bkabrda-workspace: More tests for copr listing (96511f1)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 96511f1d1fd8fd46ed7c6888ae8bfa8a0785dfe5
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 20 14:42:30 2012 +0100
More tests for copr listing
>---------------------------------------------------------------
.../tests/test_views/test_coprs_ns/test_general.py | 24 +++++++++++++++++--
1 files changed, 21 insertions(+), 3 deletions(-)
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 f5035cc..2174cb7 100644
--- a/wsgi/tests/test_views/test_coprs_ns/test_general.py
+++ b/wsgi/tests/test_views/test_coprs_ns/test_general.py
@@ -1,9 +1,27 @@
+import flask
+
from tests.coprs_test_case import CoprsTestCase
class TestCoprsShow(CoprsTestCase):
def test_show_no_entries(self):
- assert 'No entries here so far' in self.tc.get('/').data
+ assert 'No entries' in self.tc.get('/').data
- def test_show_one_entry(self, f_data1):
+ def test_show_more_entries(self, f_users, f_coprs):
r = self.tc.get('/')
- assert r.data.count('<div class=copr>') == 1
+ assert r.data.count('<div class=copr>') == 3
+
+ def test_owned_none(self, f_users, f_coprs):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u3.openid_name
+
+ r = c.get('/coprs/owned/{0}/'.format(self.u3.name))
+ assert r.data.find('No entries') != -1
+
+ def test_owned_one(self, f_users, f_coprs):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u1.openid_name
+
+ r = c.get('/coprs/owned/{0}/'.format(self.u1.name))
+ assert r.data.count('<div class=copr>') == 1
11 years, 5 months
[copr] bkabrda-workspace: Improve the fixtures (ddb1ded)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit ddb1ded849fec7c976ab8b4316060da0266b4a16
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 20 14:42:09 2012 +0100
Improve the fixtures
>---------------------------------------------------------------
wsgi/tests/coprs_test_case.py | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/wsgi/tests/coprs_test_case.py b/wsgi/tests/coprs_test_case.py
index 2f8f304..9b60e63 100644
--- a/wsgi/tests/coprs_test_case.py
+++ b/wsgi/tests/coprs_test_case.py
@@ -26,9 +26,40 @@ class CoprsTestCase(object):
self.db.engine.execute(tbl.delete())
@pytest.fixture
- def f_data1(self):
- u = models.User(openid_name = 'user1', proven = False)
- c = models.Copr(name = 'foocopr', chroots = 'fedora-18-x86_64', owner = u)
+ def f_users(self):
+ self.u1 = models.User(openid_name = 'http://user1.id.fedoraproject.org/', proven = False)
+ self.u2 = models.User(openid_name = 'http://user2.id.fedoraproject.org/', proven = False)
+ self.u3 = models.User(openid_name = 'http://user3.id.fedoraproject.org/', proven = False)
- self.db.session.add_all([u, c])
+ self.db.session.add_all([self.u1, self.u2, self.u3])
+ self.db.session.commit()
+
+ @pytest.fixture
+ def f_coprs(self):
+ self.c1 = models.Copr(name = 'foocopr', chroots = 'fedora-18-x86_64', owner = self.u1)
+ self.c2 = models.Copr(name = 'foocopr', chroots = 'fedora-17-x86_64 fedora-17-i386', owner = self.u2)
+ self.c3 = models.Copr(name = 'barcopr', chroots = 'fedora-rawhide-i386', owner = self.u2)
+
+ self.db.session.add_all([self.c1, self.c2, self.c3])
+ self.db.session.commit()
+
+ @pytest.fixture
+ def f_builds(self):
+ self.b1 = models.Build(copr = self.c1, user = self.u1, chroots = self.c1.chroots, submitted_on = 50)
+ self.b2 = models.Build(copr = self.c1, user = self.u2, chroots = 'fedora-17-x86_64', submitted_on = 10)
+ self.b3 = models.Build(copr = self.c2, user = self.u2, chroots = self.c2.chroots, submitted_on = 10)
+ self.b4 = models.Build(copr = self.c2, user = self.u2, chroots = self.c2.chroots, submitted_on = 100)
+
+ self.cp1 = models.CoprPermission(copr = self.c2, user = self.u2, approved = True)
+ self.cp2 = models.CoprPermission(copr = self.c3, user = self.u2, approved = False)
+
+ self.db.session.add_all([self.b1, self.b2, self.b3, self.b4])
+ self.db.session.commit()
+
+ @pytest.fixture
+ def f_copr_permissions(self):
+ self.cp1 = models.CoprPermission(copr = self.c2, user = self.u2, approved = True)
+ self.cp2 = models.CoprPermission(copr = self.c3, user = self.u2, approved = False)
+
+ self.db.session.add_all([self.cp1, self.cp2])
self.db.session.commit()
11 years, 5 months
[copr] bkabrda-workspace: Only drop data, not tables during tests, to speed them up (783c5a8)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 783c5a85e64df90689cf3de55bc6ce7297f9728b
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Tue Nov 20 12:30:30 2012 +0100
Only drop data, not tables during tests, to speed them up
>---------------------------------------------------------------
wsgi/tests/coprs_test_case.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/wsgi/tests/coprs_test_case.py b/wsgi/tests/coprs_test_case.py
index 943c4b9..2f8f304 100644
--- a/wsgi/tests/coprs_test_case.py
+++ b/wsgi/tests/coprs_test_case.py
@@ -21,7 +21,9 @@ class CoprsTestCase(object):
coprs.db.create_all()
def teardown_method(self, method):
- coprs.db.drop_all()
+ # delete just data, not the tables
+ for tbl in reversed(self.db.metadata.sorted_tables):
+ self.db.engine.execute(tbl.delete())
@pytest.fixture
def f_data1(self):
11 years, 5 months