[copr] master: [cron] fix syntax error (f983cbb)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit f983cbb10aedc83c29d6005641f6176ebb58887f
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 19 18:35:08 2013 +0100
[cron] fix syntax error
>---------------------------------------------------------------
copr-prune-repo | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/copr-prune-repo b/copr-prune-repo
index 8a20ea2..ebf1122 100755
--- a/copr-prune-repo
+++ b/copr-prune-repo
@@ -1,7 +1,7 @@
#!/usr/bin/bash
DAYS=14
-RESULTDIR=$(awk -F "=" '/^destdir/ {print $2}' /etc/copr/copr-be.conf
+RESULTDIR=$(awk -F "=" '/^destdir/ {print $2}' /etc/copr/copr-be.conf)
if [ ! -d $RESULTDIR ]; then
echo "ERROR: destdir ($RESULTDIR) in /etc/copr/copr-be.conf does not exist."
@@ -16,6 +16,7 @@ for REPO in $( ls -d */*/* | grep -v '/repodata$' ); do
for FAILED in $(find -name 'fail' -mtime +$DAYS); do
rm -rf $(dirname $FAILED)
echo -n .
+ done
# Query latest (sucessfull) packages
LATEST_PKGS=$(mktemp)
10 years, 5 months
[copr] master: [man] state that --chroot for create command is required (38deb95)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 38deb9580df1d03d14bd0f5a0002606e3808bbdc
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Nov 18 10:12:57 2013 +0100
[man] state that --chroot for create command is required
>---------------------------------------------------------------
man/copr-cli.1.asciidoc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/man/copr-cli.1.asciidoc b/man/copr-cli.1.asciidoc
index cee954b..969fc43 100644
--- a/man/copr-cli.1.asciidoc
+++ b/man/copr-cli.1.asciidoc
@@ -44,14 +44,14 @@ Build packages to a specified copr.
`copr-cli create [options]`
~~~~~~~~~~~~~~~~~~~~~~~~~~~
-usage: copr-cli create [-h] [--chroot CHROOTS] [--repo REPOS]
+usage: copr-cli create [-h] --chroot CHROOTS [--repo REPOS]
[--initial-pkgs INITIAL_PKGS]
[--description DESCRIPTION]
[--instructions INSTRUCTIONS]
name
--chroot::
-Chroot to use for this copr. Can be specified multiple times.
+Chroot to use for this copr. Can be specified multiple times, but at least one must be present.
--repo::
Repository to add to this copr. Can be specified multiple times.
10 years, 5 months
[copr] master: [spec] enable tests (19f627f)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 19f627f878742f6b3f6eb6e85b9fa7127a9e384e
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 15 11:32:50 2013 +0100
[spec] enable tests
>---------------------------------------------------------------
copr.spec | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/copr.spec b/copr.spec
index 3c7afc5..ead9ebf 100644
--- a/copr.spec
+++ b/copr.spec
@@ -1,4 +1,4 @@
-%global with_test 0
+%global with_test 1
%if 0%{?rhel} < 7 && 0%{?rhel} > 0
%global _pkgdocdir %{_docdir}/%{name}-%{version}
%endif
10 years, 5 months
[copr] master: [howto] add note about upgrading db schema (ab4f671)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit ab4f6718132da0220548b3750c6bee3bbe6ca190
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 15 11:31:53 2013 +0100
[howto] add note about upgrading db schema
>---------------------------------------------------------------
copr-setup.txt | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/copr-setup.txt b/copr-setup.txt
index 003369c..58ca735 100644
--- a/copr-setup.txt
+++ b/copr-setup.txt
@@ -125,6 +125,12 @@ and test the connection:
PGPASSWORD=coprpass psql -a -U copr-fe coprdb
PGPASSWORD=coprpass psql -a -h localhost -U copr-fe coprdb
+Upgrade
+=======
+After upgrade of copr-frontend you should upgrade db schema:
+cd /usr/share/copr/coprs_frontend
+alembic upgrade head
+
Make yourself admin
===================
10 years, 5 months
[copr] master: [frontend] add Build <-> Chroot relation (4d91fe2)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 4d91fe2c8a4d7bb3cc5927ba73dc336f7dca37c4
Author: Richard Marko <rmarko(a)fedoraproject.org>
Date: Tue Nov 12 17:32:36 2013 +0100
[frontend] add Build <-> Chroot relation
Signed-off-by: Richard Marko <rmarko(a)fedoraproject.org>
>---------------------------------------------------------------
coprs_frontend/coprs/models.py | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/coprs_frontend/coprs/models.py b/coprs_frontend/coprs/models.py
index 72fcc30..48cf8a0 100644
--- a/coprs_frontend/coprs/models.py
+++ b/coprs_frontend/coprs/models.py
@@ -208,9 +208,6 @@ class Build(db.Model, Serializer):
ended_on = db.Column(db.Integer)
# url of the build results
results = db.Column(db.Text)
- # status as returned by backend, see build.state for value explanation
- # (TODO: this would deserve an enum)
- status = db.Column(db.Integer)
# memory requirements for backend builder
memory_reqs = db.Column(db.Integer, default = constants.DEFAULT_BUILD_MEMORY)
# maximum allowed time of build, build will fail if exceeded
10 years, 5 months
[copr] master: [tests]: pep8 fixes (9bf6ddf)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 9bf6ddf32eeaf67d1286c2c60b491122196c9d74
Author: Richard Marko <rmarko(a)fedoraproject.org>
Date: Thu Nov 14 16:02:35 2013 +0100
[tests]: pep8 fixes
Signed-off-by: Richard Marko <rmarko(a)fedoraproject.org>
>---------------------------------------------------------------
coprs_frontend/tests/coprs_test_case.py | 94 ++++++++++++++++++++++---------
1 files changed, 67 insertions(+), 27 deletions(-)
diff --git a/coprs_frontend/tests/coprs_test_case.py b/coprs_frontend/tests/coprs_test_case.py
index 4685b25..8ff9c60 100644
--- a/coprs_frontend/tests/coprs_test_case.py
+++ b/coprs_frontend/tests/coprs_test_case.py
@@ -10,9 +10,10 @@ import coprs
from coprs import helpers
from coprs import models
-from coprs.logic.builds_logic import BuildsLogic
+
class CoprsTestCase(object):
+
def setup_method(self, method):
self.tc = coprs.app.test_client()
self.app = coprs.app
@@ -23,7 +24,8 @@ class CoprsTestCase(object):
self.helpers = helpers
self.backend_passwd = coprs.app.config['BACKEND_PASSWORD']
# create datadir if it doesn't exist
- datadir = os.path.commonprefix([self.app.config['DATABASE'], self.app.config['OPENID_STORE']])
+ datadir = os.path.commonprefix(
+ [self.app.config['DATABASE'], self.app.config['OPENID_STORE']])
if not os.path.exists(datadir):
os.makedirs(datadir)
coprs.db.create_all()
@@ -36,7 +38,8 @@ class CoprsTestCase(object):
@property
def auth_header(self):
- return {'Authorization': 'Basic ' + base64.b64encode('doesntmatter:{0}'.format(self.backend_passwd))}
+ return {'Authorization': 'Basic ' +
+ base64.b64encode('doesntmatter:{0}'.format(self.backend_passwd))}
@pytest.fixture
def f_db(self):
@@ -44,26 +47,42 @@ class CoprsTestCase(object):
@pytest.fixture
def f_users(self):
- self.u1 = models.User(openid_name=u'http://user1.id.fedoraproject.org/', proven=False, admin=True, mail='user1(a)foo.bar')
- self.u2 = models.User(openid_name=u'http://user2.id.fedoraproject.org/', proven = False, mail='user2(a)spam.foo')
- self.u3 = models.User(openid_name=u'http://user3.id.fedoraproject.org/', proven=False, mail='baz(a)bar.bar')
+ self.u1 = models.User(
+ openid_name=u'http://user1.id.fedoraproject.org/',
+ proven=False,
+ admin=True,
+ mail='user1(a)foo.bar')
+
+ self.u2 = models.User(
+ openid_name=u'http://user2.id.fedoraproject.org/',
+ proven=False,
+ mail='user2(a)spam.foo')
+
+ self.u3 = models.User(
+ openid_name=u'http://user3.id.fedoraproject.org/',
+ proven=False,
+ mail='baz(a)bar.bar')
self.db.session.add_all([self.u1, self.u2, self.u3])
@pytest.fixture
def f_coprs(self):
- self.c1 = models.Copr(name = u'foocopr', owner = self.u1)
- self.c2 = models.Copr(name = u'foocopr', owner = self.u2)
- self.c3 = models.Copr(name = u'barcopr', owner = self.u2)
+ self.c1 = models.Copr(name=u'foocopr', owner=self.u1)
+ self.c2 = models.Copr(name=u'foocopr', owner=self.u2)
+ self.c3 = models.Copr(name=u'barcopr', owner=self.u2)
self.db.session.add_all([self.c1, self.c2, self.c3])
@pytest.fixture
def f_mock_chroots(self):
- self.mc1 = models.MockChroot(os_release='fedora', os_version='18', arch='x86_64', is_active=True)
- self.mc2 = models.MockChroot(os_release='fedora', os_version='17', arch='x86_64', is_active=True)
- self.mc3 = models.MockChroot(os_release='fedora', os_version='17', arch='i386', is_active=True)
- self.mc4 = models.MockChroot(os_release='fedora', os_version='rawhide', arch='i386', is_active=True)
+ self.mc1 = models.MockChroot(
+ os_release='fedora', os_version='18', arch='x86_64', is_active=True)
+ self.mc2 = models.MockChroot(
+ os_release='fedora', os_version='17', arch='x86_64', is_active=True)
+ self.mc3 = models.MockChroot(
+ os_release='fedora', os_version='17', arch='i386', is_active=True)
+ self.mc4 = models.MockChroot(
+ os_release='fedora', os_version='rawhide', arch='i386', is_active=True)
# only bind to coprs if the test has used the f_coprs fixture
if hasattr(self, 'c1'):
@@ -90,10 +109,14 @@ class CoprsTestCase(object):
@pytest.fixture
def f_builds(self):
- self.b1 = models.Build(copr = self.c1, user = self.u1, submitted_on = 50, started_on = 100)
- self.b2 = models.Build(copr = self.c1, user = self.u2, submitted_on = 10, ended_on = 150)
- self.b3 = models.Build(copr = self.c2, user = self.u2, submitted_on = 10)
- self.b4 = models.Build(copr = self.c2, user = self.u2, submitted_on = 100)
+ self.b1 = models.Build(
+ copr=self.c1, user=self.u1, submitted_on=50, started_on=100)
+ self.b2 = models.Build(
+ copr=self.c1, user=self.u2, submitted_on=10, ended_on=150)
+ self.b3 = models.Build(
+ copr=self.c2, user=self.u2, submitted_on=10)
+ self.b4 = models.Build(
+ copr=self.c2, user=self.u2, submitted_on=100)
for build in [self.b1, self.b2, self.b3, self.b4]:
self.db.session.add(build)
@@ -109,27 +132,46 @@ class CoprsTestCase(object):
@pytest.fixture
def f_copr_permissions(self):
- self.cp1 = models.CoprPermission(copr = self.c2, user = self.u1, copr_builder = helpers.PermissionEnum('approved'), copr_admin = helpers.PermissionEnum('nothing'))
- self.cp2 = models.CoprPermission(copr = self.c3, user = self.u3, copr_builder = helpers.PermissionEnum('nothing'), copr_admin = helpers.PermissionEnum('nothing'))
- self.cp3 = models.CoprPermission(copr = self.c3, user = self.u1, copr_builder = helpers.PermissionEnum('request'), copr_admin = helpers.PermissionEnum('approved'))
+ self.cp1 = models.CoprPermission(
+ copr=self.c2,
+ user=self.u1,
+ copr_builder=helpers.PermissionEnum('approved'),
+ copr_admin=helpers.PermissionEnum('nothing'))
+
+ self.cp2 = models.CoprPermission(
+ copr=self.c3,
+ user=self.u3,
+ copr_builder=helpers.PermissionEnum('nothing'),
+ copr_admin=helpers.PermissionEnum('nothing'))
+
+ self.cp3 = models.CoprPermission(
+ copr=self.c3,
+ user=self.u1,
+ copr_builder=helpers.PermissionEnum('request'),
+ copr_admin=helpers.PermissionEnum('approved'))
self.db.session.add_all([self.cp1, self.cp2, self.cp3])
@pytest.fixture
def f_actions(self):
- # if using actions, we need to flush coprs into db, so that we can get their ids
+ # if using actions, we need to flush coprs into db, so that we can get
+ # their ids
self.f_db()
self.a1 = models.Action(action_type=helpers.ActionTypeEnum('rename'),
object_type='copr',
object_id=self.c1.id,
- old_value='{0}/{1}'.format(self.c1.owner.name, self.c1.name),
- new_value='{0}/new_name'.format(self.c1.owner.name),
+ old_value='{0}/{1}'.format(
+ self.c1.owner.name, self.c1.name),
+ new_value='{0}/new_name'.format(
+ self.c1.owner.name),
created_on=int(time.time()))
self.a2 = models.Action(action_type=helpers.ActionTypeEnum('rename'),
object_type='copr',
object_id=self.c2.id,
- old_value='{0}/{1}'.format(self.c2.owner.name, self.c2.name),
- new_value='{0}/new_name2'.format(self.c2.owner.name),
+ old_value='{0}/{1}'.format(
+ self.c2.owner.name, self.c2.name),
+ new_value='{0}/new_name2'.format(
+ self.c2.owner.name),
created_on=int(time.time()))
self.a3 = models.Action(action_type=helpers.ActionTypeEnum('delete'),
object_type='copr',
@@ -141,8 +183,6 @@ class CoprsTestCase(object):
self.db.session.add_all([self.a1, self.a2, self.a3])
-
-
class TransactionDecorator(object):
"""
10 years, 5 months
[copr] master: [tests]: replace test_allowed_one (dbc6384)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit dbc6384556c9b7efd9502445ce4f7344410178b6
Author: Richard Marko <rmarko(a)fedoraproject.org>
Date: Thu Nov 14 16:10:07 2013 +0100
[tests]: replace test_allowed_one
Replaces failing test_allowed_one which doesn't make much sense
with test_allowed_one_but_... which checks the same thing.
Signed-off-by: Richard Marko <rmarko(a)fedoraproject.org>
>---------------------------------------------------------------
copr.spec | 5 +----
.../test_views/test_coprs_ns/test_coprs_general.py | 8 +-------
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/copr.spec b/copr.spec
index 5203312..3c7afc5 100644
--- a/copr.spec
+++ b/copr.spec
@@ -263,10 +263,7 @@ install -p -m 644 man/%{name}-selinux-relabel.8 %{buildroot}/%{_mandir}/man8/
%check
%if ! 0%{?with_test:1}
pushd coprs_frontend
- TMPFILE=$(mktemp)
- COPR_CONFIG="$(pwd)/config/copr_unit_test.conf" ./manage.py test | tee $TMPFILE
- # remove this when tests are fixed
- grep "1 failed, 65 passed" $TMPFILE
+ COPR_CONFIG="$(pwd)/config/copr_unit_test.conf" ./manage.py test
popd
%endif
diff --git a/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
index 179dad7..a05c54d 100644
--- a/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
+++ b/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
@@ -35,14 +35,8 @@ class TestCoprsAllowed(CoprsTestCase):
r = self.test_client.get('/coprs/{0}/allowed/'.format(self.u3.name))
assert 'No projects...' in r.data
- @TransactionDecorator('u2')
- def test_allowed_one(self, f_users, f_coprs, f_copr_permissions, f_db):
- self.db.session.add(self.u1)
- r = self.test_client.get('/coprs/{0}/allowed/'.format(self.u2.name))
- assert r.data.count('<div class="copr">') == 1
-
@TransactionDecorator('u1')
- def test_allowed_one_but_asked_for_one_more(self, f_users, f_coprs, f_copr_permissions, f_db):
+ def test_allowed_one(self, f_users, f_coprs, f_copr_permissions, f_db):
self.db.session.add(self.u1)
r = self.test_client.get('/coprs/{0}/allowed/'.format(self.u1.name))
assert r.data.count('<div class="copr">') == 1
10 years, 5 months
[copr] master: [frontend] rewrite backend view to use Build <-> Chroot relation (6f1c602)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 6f1c6021f435be555befd7cf267cc053d06aa07e
Author: Richard Marko <rmarko(a)fedoraproject.org>
Date: Wed Nov 13 16:11:57 2013 +0100
[frontend] rewrite backend view to use Build <-> Chroot relation
Fix BuildsLogic to update status of chroot objects
instead of Build directly, drop some unused parameters.
Signed-off-by: Richard Marko <rmarko(a)fedoraproject.org>
>---------------------------------------------------------------
.../coprs/views/coprs_ns/coprs_builds.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py b/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
index da87f7c..aa35ea3 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
@@ -73,7 +73,7 @@ def copr_new_build(username, coprname):
@login_required
def copr_cancel_build(username, coprname, build_id):
# only the user who ran the build can cancel it
- build = builds_logic.BuildsLogic.get(flask.g.user, build_id).first()
+ build = builds_logic.BuildsLogic.get(build_id).first()
if not build: # hey, this Build doesn't exist
return page_not_found('Build with id {0} does not exist.'.format(build_id))
try:
@@ -90,7 +90,7 @@ def copr_cancel_build(username, coprname, build_id):
@coprs_ns.route('/<username>/<coprname>/repeat_build/<int:build_id>/', methods = ['POST'])
@login_required
def copr_repeat_build(username, coprname, build_id):
- build = builds_logic.BuildsLogic.get(flask.g.user, build_id).first()
+ build = builds_logic.BuildsLogic.get(build_id).first()
copr = coprs_logic.CoprsLogic.get(flask.g.user, username=username, coprname=coprname).first()
if not build: # hey, this Build doesn't exist
10 years, 5 months
[copr] master: [frontend]: add copr monitor (9c8e3cc)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 9c8e3cc2858e863ae3c349ec70b09f75cb1a4e31
Author: Richard Marko <rmarko(a)fedoraproject.org>
Date: Thu Nov 14 16:58:55 2013 +0100
[frontend]: add copr monitor
Signed-off-by: Richard Marko <rmarko(a)fedoraproject.org>
>---------------------------------------------------------------
coprs_frontend/coprs/models.py | 11 ++++++++
coprs_frontend/coprs/static/copr.css | 4 +++
coprs_frontend/coprs/templates/coprs/detail.html | 3 ++
.../coprs/templates/coprs/detail/monitor.html | 28 ++++++++++++++++++++
.../coprs/views/coprs_ns/coprs_general.py | 17 ++++++++++++
5 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/coprs_frontend/coprs/models.py b/coprs_frontend/coprs/models.py
index 48cf8a0..e494c75 100644
--- a/coprs_frontend/coprs/models.py
+++ b/coprs_frontend/coprs/models.py
@@ -297,6 +297,17 @@ class BuildChroot(db.Model, Serializer):
build = db.relationship('Build', backref=db.backref('build_chroots'))
status = db.Column(db.Integer, default=helpers.StatusEnum('pending'))
+ @property
+ def name(self):
+ """ Textual representation of name of this chroot """
+ return self.mock_chroot.chroot_name
+
+ @property
+ def state(self):
+ """ Return text representation of status of this build chroot """
+ return helpers.StatusEnum(self.status)
+
+
class LegalFlag(db.Model, Serializer):
id = db.Column(db.Integer, primary_key=True)
diff --git a/coprs_frontend/coprs/static/copr.css b/coprs_frontend/coprs/static/copr.css
index 97e3510..451af8b 100644
--- a/coprs_frontend/coprs/static/copr.css
+++ b/coprs_frontend/coprs/static/copr.css
@@ -318,6 +318,10 @@ table.releases tr.release-end {
border-bottom: 3px solid #f2f2f2;
}
+table.monitor td {
+ padding: 0 20px;
+}
+
form.legal-flag, form.legal-flag input {
color: #888888;
margin-top: 5px;
diff --git a/coprs_frontend/coprs/templates/coprs/detail.html b/coprs_frontend/coprs/templates/coprs/detail.html
index 749ffb6..cc4535c 100644
--- a/coprs_frontend/coprs/templates/coprs/detail.html
+++ b/coprs_frontend/coprs/templates/coprs/detail.html
@@ -17,6 +17,9 @@
<li class="{% block builds_selected %}unselected{% endblock %}">
<a href="{{ url_for('coprs_ns.copr_builds', username = copr.owner.name, coprname = copr.name) }}">Builds</a>
</li>
+ <li class="{% block monitor_selected %}unselected{% endblock %}">
+ <a href="{{ url_for('coprs_ns.copr_build_monitor', username = copr.owner.name, coprname = copr.name) }}">Monitor</a>
+ </li>
{% if g.user and g.user.can_build_in(copr) %}
<li class="{% block new_build_selected %}unselected{% endblock %}">
<a href="{{ url_for('coprs_ns.copr_add_build', username = copr.owner.name, coprname = copr.name) }}">New Build</a>
diff --git a/coprs_frontend/coprs/templates/coprs/detail/monitor.html b/coprs_frontend/coprs/templates/coprs/detail/monitor.html
new file mode 100644
index 0000000..e936724
--- /dev/null
+++ b/coprs_frontend/coprs/templates/coprs/detail/monitor.html
@@ -0,0 +1,28 @@
+{% extends "coprs/detail.html" %}
+{% block title %}Monitor {{ copr.owner.name }}/{{ copr.name }}{% endblock %}
+{% block monitor_selected %}selected{% endblock %}
+
+{% block detail_body %}
+ {% if build %}
+ <p>
+ Latest build status:
+ <strong>{{ build.state }}</strong>
+ </p>
+ {% if not build.canceled %}
+ <table class="monitor">
+ <tr>
+ <th>Chroot</th>
+ <th>State</th>
+ </tr>
+ {% for chroot in build.build_chroots %}
+ <tr class="build-{{ chroot.state }}">
+ <td>{{ chroot.name }}</td>
+ <td>{{ chroot.state }}</td>
+ </tr>
+ {% endfor %}
+ </table>
+ {% endif %}
+ {% else %}
+ <h2>No builds so far.</h2>
+ {% endif %}
+{% endblock %}
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index 5874543..1d3750f 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -344,3 +344,20 @@ def generate_repo_file(username, coprname, chroot):
response.mimetype='text/plain'
response.headers['Content-Disposition'] = 'filename=%s.repo' % reponame
return response
+
+(a)coprs_ns.route('/<username>/<coprname>/monitor/')
+def copr_build_monitor(username, coprname):
+ query = coprs_logic.CoprsLogic.get(flask.g.user, username, coprname, with_mock_chroots=True)
+ form = forms.CoprLegalFlagForm()
+ try:
+ copr = query.one()
+ except sqlalchemy.orm.exc.NoResultFound:
+ return page_not_found('Copr with name {0} does not exist.'.format(coprname))
+
+ builds_query = builds_logic.BuildsLogic.get_multiple(flask.g.user, copr=copr)
+ build = builds_query.first()
+
+ return flask.render_template('coprs/detail/monitor.html',
+ copr=copr,
+ build=build,
+ form=form)
10 years, 5 months
[copr] master: [tests]: fix for BuildChroots & new backend view (c3501b9)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit c3501b96ba2217c538eb7148e1b9f0d48632676a
Author: Richard Marko <rmarko(a)fedoraproject.org>
Date: Thu Nov 14 15:30:27 2013 +0100
[tests]: fix for BuildChroots & new backend view
Signed-off-by: Richard Marko <rmarko(a)fedoraproject.org>
>---------------------------------------------------------------
.../test_backend_ns/test_backend_general.py | 54 ++++++++++++-------
.../test_views/test_coprs_ns/test_coprs_builds.py | 12 ++---
.../test_views/test_coprs_ns/test_coprs_general.py | 35 ++++++++++---
3 files changed, 66 insertions(+), 35 deletions(-)
diff --git a/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py b/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py
index 235ed98..322f01d 100644
--- a/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py
+++ b/coprs_frontend/tests/test_views/test_backend_ns/test_backend_general.py
@@ -1,20 +1,22 @@
import json
-import flask
-
from coprs.signals import build_finished
from tests.coprs_test_case import CoprsTestCase
+
class TestWaitingBuilds(CoprsTestCase):
def test_no_waiting_builds(self):
- assert '"builds": []' in self.tc.get('/backend/waiting_builds/').data
+ assert '"builds": []' in self.tc.get('/backend/waiting/', headers=self.auth_header).data
+
+ def test_waiting_build_only_lists_not_started_or_ended(
+ self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
+
+ r = self.tc.get('/backend/waiting/', headers=self.auth_header)
+ assert len(json.loads(r.data)['builds']) == 4
- def test_waiting_build_only_lists_not_started_or_ended(self, f_users, f_coprs, f_builds, f_db):
- r = self.tc.get('/backend/waiting_builds/')
- assert len(json.loads(r.data)['builds']) == 2
class TestUpdateBuilds(CoprsTestCase):
- data1="""
+ data1= """
{
"builds":[
{
@@ -33,6 +35,7 @@ class TestUpdateBuilds(CoprsTestCase):
"id": 1,
"copr_id": 2,
"status": 1,
+ "chroot": "fedora-18-x86_64",
"ended_on": 12345
}
]
@@ -44,13 +47,14 @@ class TestUpdateBuilds(CoprsTestCase):
{
"id": 1,
"copr_id": 2,
- "results": "http://server/results/foo/bar/",
"started_on": 1234
},
{
"id": 2,
"copr_id": 1,
"status": 0,
+ "chroot": "fedora-18-x86_64",
+ "results": "http://server/results/foo/bar/",
"ended_on": 123456
},
{
@@ -68,13 +72,17 @@ class TestUpdateBuilds(CoprsTestCase):
]
}"""
def test_updating_requires_password(self, f_users, f_coprs, f_builds, f_db):
- r = self.tc.post('/backend/update_builds/',
+ r = self.tc.post('/backend/update/',
content_type = 'application/json',
data = '')
assert 'You have to provide the correct password' in r.data
def test_update_build_started(self, f_users, f_coprs, f_builds, f_db):
- r = self.tc.post('/backend/update_builds/',
+ self.b1.started_on = None
+ self.db.session.add(self.b1)
+ self.db.session.commit()
+
+ r = self.tc.post('/backend/update/',
content_type='application/json',
headers=self.auth_header,
data=self.data1)
@@ -85,8 +93,8 @@ class TestUpdateBuilds(CoprsTestCase):
assert updated.results == 'http://server/results/foo/bar/'
assert updated.started_on == 1234
- def test_update_build_ended(self, f_users, f_coprs, f_builds, f_db):
- r = self.tc.post('/backend/update_builds/',
+ def test_update_build_ended(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
+ r = self.tc.post('/backend/update/',
content_type='application/json',
headers=self.auth_header,
data=self.data2)
@@ -97,8 +105,14 @@ class TestUpdateBuilds(CoprsTestCase):
assert updated.status == 1
assert updated.ended_on == 12345
- def test_update_more_existent_and_non_existent_builds(self, f_users, f_coprs, f_builds, f_db):
- r = self.tc.post('/backend/update_builds/',
+ def test_update_more_existent_and_non_existent_builds(
+ self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
+
+ self.b1.started_on = None
+ self.db.session.add(self.b1)
+ self.db.session.commit()
+
+ r = self.tc.post('/backend/update/',
content_type='application/json',
headers=self.auth_header,
data=self.data3)
@@ -107,11 +121,11 @@ class TestUpdateBuilds(CoprsTestCase):
assert sorted(json.loads(r.data)["non_existing_builds_ids"]) == [123321, 1234321]
started = self.models.Build.query.filter(self.models.Build.id==1).first()
- assert started.results == 'http://server/results/foo/bar/'
assert started.started_on == 1234
ended = self.models.Build.query.filter(self.models.Build.id==2).first()
assert ended.status == 0
+ assert ended.results == 'http://server/results/foo/bar/'
assert ended.ended_on == 123456
def test_build_ended_emmits_signal(self, f_users, f_coprs, f_builds, f_db):
@@ -120,7 +134,7 @@ class TestUpdateBuilds(CoprsTestCase):
def test_receiver(sender, **kwargs):
signals_received.append(kwargs['build'])
build_finished.connect(test_receiver)
- r = self.tc.post('/backend/update_builds/',
+ r = self.tc.post('/backend/update/',
content_type='application/json',
headers=self.auth_header,
data=self.data3)
@@ -130,10 +144,10 @@ class TestUpdateBuilds(CoprsTestCase):
class TestWaitingActions(CoprsTestCase):
def test_no_waiting_builds(self):
- assert '"actions": []' in self.tc.get('/backend/waiting_actions/').data
+ assert '"actions": []' in self.tc.get('/backend/waiting/', headers=self.auth_header).data
def test_waiting_build_only_lists_not_started_or_ended(self, f_users, f_coprs, f_actions, f_db):
- r = self.tc.get('/backend/waiting_actions/')
+ r = self.tc.get('/backend/waiting/', headers=self.auth_header)
assert len(json.loads(r.data)['actions']) == 2
class TestUpdateActions(CoprsTestCase):
@@ -173,7 +187,7 @@ class TestUpdateActions(CoprsTestCase):
}"""
def test_update_one_action(self, f_users, f_coprs, f_actions, f_db):
- r = self.tc.post('/backend/update_actions/',
+ r = self.tc.post('/backend/update/',
content_type='application/json',
headers=self.auth_header,
data=self.data1)
@@ -186,7 +200,7 @@ class TestUpdateActions(CoprsTestCase):
assert updated.ended_on == 123
def test_update_more_existent_and_non_existent_builds(self, f_users, f_coprs, f_actions, f_db):
- r = self.tc.post('/backend/update_actions/',
+ r = self.tc.post('/backend/update/',
content_type='application/json',
headers=self.auth_header,
data=self.data2)
diff --git a/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py
index 60bafb7..dc66562 100644
--- a/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py
+++ b/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py
@@ -1,15 +1,13 @@
-import flask
-
from tests.coprs_test_case import CoprsTestCase, TransactionDecorator
class TestCoprShowBuilds(CoprsTestCase):
- def test_copr_show_builds(self, f_users, f_coprs, f_builds, f_db):
+ def test_copr_show_builds(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
r = self.tc.get('/coprs/{0}/{1}/builds/'.format(self.u2.name, self.c2.name))
assert r.data.count('<tr class="build-') == 2
class TestCoprAddBuild(CoprsTestCase):
@TransactionDecorator('u1')
- def test_copr_owner_can_add_build(self, f_users, f_coprs, f_db):
+ def test_copr_owner_can_add_build(self, f_users, f_coprs, f_mock_chroots, f_db):
self.db.session.add_all([self.u1, self.c1])
r = self.test_client.post('/coprs/{0}/{1}/new_build/'.format(self.u1.name, self.c1.name),
data = {'pkgs': 'http://testing'},
@@ -17,7 +15,7 @@ class TestCoprAddBuild(CoprsTestCase):
assert self.models.Build.query.first().pkgs == 'http://testing'
@TransactionDecorator('u1')
- def test_copr_allowed_user_can_add_build(self, f_users, f_coprs, f_copr_permissions, f_db):
+ def test_copr_allowed_user_can_add_build(self, f_users, f_coprs, f_mock_chroots, f_copr_permissions, f_db):
self.db.session.add_all([self.u2, self.c2])
r = self.test_client.post('/coprs/{0}/{1}/new_build/'.format(self.u2.name, self.c2.name),
data = {'pkgs': 'http://testing'},
@@ -44,7 +42,7 @@ class TestCoprAddBuild(CoprsTestCase):
class TestCoprCancelBuild(CoprsTestCase):
@TransactionDecorator('u1')
- def test_copr_build_submitter_can_cancel_build(self, f_users, f_coprs, f_builds, f_db):
+ def test_copr_build_submitter_can_cancel_build(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
self.db.session.add_all([self.u1, self.c1, self.b1])
r = self.test_client.post('/coprs/{0}/{1}/cancel_build/{2}/'.format(self.u1.name, self.c1.name, self.b1.id),
data = {},
@@ -53,7 +51,7 @@ class TestCoprCancelBuild(CoprsTestCase):
@TransactionDecorator('u2')
- def test_copr_build_non_submitter_cannot_cancel_build(self, f_users, f_coprs, f_builds, f_db):
+ def test_copr_build_non_submitter_cannot_cancel_build(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
self.db.session.add_all([self.u1, self.c1, self.b1])
r = self.test_client.post('/coprs/{0}/{1}/cancel_build/{2}/'.format(self.u1.name, self.c1.name, self.b1.id),
data = {},
diff --git a/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
index e02a0b3..179dad7 100644
--- a/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
+++ b/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_general.py
@@ -1,4 +1,3 @@
-import flask
import pytest
from flexmock import flexmock
@@ -132,7 +131,7 @@ class TestCoprDetail(CoprsTestCase):
assert r.status_code == 200
assert self.c1.name in r.data
- def test_copr_detail_contains_builds(self, f_users, f_coprs, f_builds, f_db):
+ def test_copr_detail_contains_builds(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
r = self.tc.get('/coprs/{0}/{1}/builds/'.format(self.u1.name, self.c1.name))
assert r.data.count('<tr class="build') == 2
@@ -173,13 +172,13 @@ class TestCoprDetail(CoprsTestCase):
assert '/cancel_build/' not in r.data
@TransactionDecorator('u1')
- def test_copr_detail_doesnt_allow_non_submitter_to_cancel_build(self, f_users, f_coprs, f_builds, f_db):
+ def test_copr_detail_doesnt_allow_non_submitter_to_cancel_build(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
self.db.session.add_all([self.u2, self.c2])
r = self.test_client.get('/coprs/{0}/{1}/builds/'.format(self.u2.name, self.c2.name))
assert '/cancel_build/' not in r.data
@TransactionDecorator('u2')
- def test_copr_detail_allows_submitter_to_cancel_build(self, f_users, f_coprs, f_builds, f_db):
+ def test_copr_detail_allows_submitter_to_cancel_build(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
self.db.session.add_all([self.u2, self.c2])
r = self.test_client.get('/coprs/{0}/{1}/builds/'.format(self.u2.name, self.c2.name))
assert '/cancel_build/' in r.data
@@ -393,19 +392,39 @@ class TestCoprRepoGeneration(CoprsTestCase):
@pytest.fixture
def f_custom_builds(self):
''' Custom builds are used in order not to break the default ones '''
- self.b5 = self.models.Build(copr=self.c1, user=self.u1, chroots='fedora-18-x86_64', submitted_on=9, ended_on=200, results='http://bar.baz', status=1)
- self.b6 = self.models.Build(copr=self.c1, user=self.u1, chroots='fedora-18-x86_64', submitted_on=11)
- self.b7 = self.models.Build(copr=self.c1, user=self.u1, chroots='fedora-18-x86_64', submitted_on=10, ended_on=150, results='http://bar.baz', status=1)
+ self.b5 = self.models.Build(copr=self.c1, user=self.u1, submitted_on=9, ended_on=200, results='http://bar.baz')
+ self.b6 = self.models.Build(copr=self.c1, user=self.u1, submitted_on=11)
+ self.b7 = self.models.Build(copr=self.c1, user=self.u1, submitted_on=10, ended_on=150, results='http://bar.baz')
self.mc1 = self.models.MockChroot(os_release='fedora', os_version='18', arch='x86_64')
self.cc1 = self.models.CoprChroot(mock_chroot = self.mc1, copr = self.c1)
+
+
+ # assign with chroots
+ for build in [self.b5, self.b6, self.b7]:
+ self.db.session.add(
+ self.models.BuildChroot(
+ build=build,
+ mock_chroot=self.mc1
+ )
+ )
+
self.db.session.add_all([self.b5, self.b6, self.b7, self.mc1, self.cc1])
@pytest.fixture
def f_not_finished_builds(self):
''' Custom builds are used in order not to break the default ones '''
- self.b8 = self.models.Build(copr=self.c1, user=self.u1, chroots='fedora-18-x86_64', submitted_on=11)
+ self.b8 = self.models.Build(copr=self.c1, user=self.u1, submitted_on=11)
self.mc1 = self.models.MockChroot(os_release='fedora', os_version='18', arch='x86_64')
self.cc1 = self.models.CoprChroot(mock_chroot = self.mc1, copr = self.c1)
+
+ # assign with chroot
+ self.db.session.add(
+ self.models.BuildChroot(
+ build=self.b8,
+ mock_chroot=self.mc1
+ )
+ )
+
self.db.session.add_all([self.b8, self.mc1, self.cc1])
def test_fail_on_missing_dash(self):
10 years, 5 months