[copr] master: [frontend][API] sphinx doc for API_2, initial commit (82ad387)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 82ad387b4db3ce1c6d87c85bcf778ac4a30279b4
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Sep 2 16:50:15 2015 +0200
[frontend][API] sphinx doc for API_2, initial commit
>---------------------------------------------------------------
frontend/copr-frontend.spec | 2 +
{backend/docs => frontend/docs/api_2}/Makefile | 34 +++-
frontend/docs/api_2/source/Resources/project.rst | 230 ++++++++++++++++++++
.../docs => frontend/docs/api_2}/source/conf.py | 106 ++++-----
frontend/docs/api_2/source/index.rst | 63 ++++++
5 files changed, 372 insertions(+), 63 deletions(-)
diff --git a/frontend/copr-frontend.spec b/frontend/copr-frontend.spec
index 3377f4a..01b9aec 100644
--- a/frontend/copr-frontend.spec
+++ b/frontend/copr-frontend.spec
@@ -89,6 +89,8 @@ BuildRequires: python-markdown
BuildRequires: pytz
BuildRequires: python-flask-restful
BuildRequires: python-marshmallow >= 2.0.0
+BuildRequires: python-sphinx
+BuildRequires: python-sphinxcontrib-httpdomain
%description
COPR is lightweight build system. It allows you to create new project in WebUI,
diff --git a/backend/docs/Makefile b/frontend/docs/api_2/Makefile
similarity index 79%
copy from backend/docs/Makefile
copy to frontend/docs/api_2/Makefile
index 87a774f..baf991e 100644
--- a/backend/docs/Makefile
+++ b/frontend/docs/api_2/Makefile
@@ -7,6 +7,11 @@ SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
@@ -29,17 +34,20 @@ help:
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
- -rm -rf $(BUILDDIR)/*
+ rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@@ -77,17 +85,17 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/copr-backend.qhcp"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/CoprApi2.qhcp"
@echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/copr-backend.qhc"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/CoprApi2.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
- @echo "# mkdir -p $$HOME/.local/share/devhelp/copr-backend"
- @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/copr-backend"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/CoprApi2"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/CoprApi2"
@echo "# devhelp"
epub:
@@ -108,6 +116,12 @@ latexpdf:
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@@ -151,3 +165,13 @@ doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/frontend/docs/api_2/source/Resources/project.rst b/frontend/docs/api_2/source/Resources/project.rst
new file mode 100644
index 0000000..2a9f31c
--- /dev/null
+++ b/frontend/docs/api_2/source/Resources/project.rst
@@ -0,0 +1,230 @@
+Project
+=======
+
+Project resource represents copr projects and operations with them.
+
+Structure of the project entity
+-------------------------------
+
+**An example**:
+
+.. code-block:: javascript
+
+ {
+ "description": "A recent stable release of Ruby with Rails 3.2.8 and ... ",
+ "disable_createrepo": false,
+ "repos": [
+ "http://copr-be.cloud.fedoraproject.org/results/msuchy/scl-utils/epel-6-$b...",
+ "http://copr-be.cloud.fedoraproject.org/results/rhscl/httpd24/epel-6-$base...",
+ ],
+ "contact": null,
+ "owner": "rhscl",
+ "build_enable_net": true,
+ "instructions": "",
+ "homepage": null,
+ "id": 479,
+ "name": "ruby193"
+ }
+
+
+Project fields
+~~~~~~~~~~~~~~
+================== ==================== ========= ===============
+Field Type Can edit? Description
+================== ==================== ========= ===============
+id number no unique identifier
+owner string no login of the project owner
+name string no name of the project, MUST be specified during a project creation
+description string yes project description
+instructions string yes installation instructions
+homepage string(URL) yes project homepage
+contact string(URL or email) yes contact with the project maintainer
+disable_createrepo bool yes disables automatic repository metadata generation
+build_enable_net bool yes set default value for new builds option ``enable_net``
+================== ==================== ========= ===============
+
+
+.. http:get:: /api_2/projects
+
+ Returns a list of Copr projects according to the given query parameters
+
+ **Example request**:
+
+ .. sourcecode:: http
+
+ GET /api_2/projects HTTP/1.1
+ Host: copr.fedoraproject.org
+ Accept: application/json
+
+ **Response**:
+
+ .. sourcecode:: http
+
+ HTTP/1.1 200 OK
+ Content-Type: application/json
+
+ {
+ "_links": {
+ "self": {
+ "href": "/api_2/projects"
+ }
+ },
+ "projects": [
+ {
+ "project": {
+ "description": "Lightweight buildsystem - upstream releases. Usually build few days before it land in Fedora.",
+ "disable_createrepo": false,
+ "repos": [],
+ "contact": null,
+ "owner": "msuchy",
+ "build_enable_net": false,
+ "instructions": "See https://fedorahosted.org/copr/ for more details.",
+ "homepage": null,
+ "id": 1,
+ "name": "copr"
+ },
+ "_links": { }
+ },
+ ]
+ }
+
+ :query search_query: filter project using full-text search
+ :query owner: select only projects owned by this user
+ :query name: select only projects with this name
+ :query offset: offset number, default value is 0
+ :query limit: limit number, default value is 100
+
+ :statuscode 200: no error
+
+.. http:post:: /api_2/projects
+
+ **REQUIRE AUTH**
+
+ Creates new Copr project.
+
+ Additionally to described before `Project fields`_ the user could specify field ``chroots`` which contains list of chroots to be enabled.
+ Available chroots could be obtained from MockChrootResource_
+
+ **Example request**:
+
+ .. sourcecode:: http
+
+ POST /api_2/projects HTTP/1.1
+ Host: copr.fedoraproject.org
+ Authorization: Basic base64=encoded=string
+ Accept: application/json
+
+ {
+ "disable_createrepo": false,
+ "build_enable_net": true,
+ "name": "foobar",
+ "chroots": [
+ "fedora-22-x86_64",
+ "fedora-22-i386",
+ ]
+ }
+
+
+ **Response**:
+
+ .. sourcecode:: http
+
+ HTTP/1.1 201 CREATED
+ Location: /api_2/projects/<new project id>
+
+ :resheader Location: contains URL to the newly created project entity
+
+ :statuscode 201: project was successfully created
+ :statuscode 400: given data for project creation doesn't satisfy some requirements
+ :statuscode 401: the user already has project with the same name
+ :statuscode 403: authorization failed
+
+
+.. http:get:: /api_2/projects/(int:project_id)
+
+ Returns details about Copr project
+
+ :param project_id: a unique identifier of the Copr project.
+
+ :query bool show_builds: embed Build_ entities owned by this project into the result, default is False
+ :query bool show_chroots: embed ProjectChroot_ sub-resources into the result, default is False
+
+ :statuscode 200: no error
+ :statuscode 404: project not found
+
+ **Example request**
+
+ .. sourcecode:: http
+
+ GET /api_2/projects/2482 HTTP/1.1
+ Host: copr.fedoraproject.org
+ Accept: application/json
+
+ **Response**
+
+ .. sourcecode:: http
+ HTTP/1.1 200 OK
+ Content-Type: application/json
+
+ {
+ "project": {
+ "description": "A simple KDE respin",
+ "disable_createrepo": false,
+ "repos": [],
+ "contact": null,
+ "owner": "jmiahman",
+ "build_enable_net": true,
+ "instructions": "",
+ "homepage": null,
+ "id": 2482,
+ "name": "Synergy-Linux"
+ },
+ "project_chroots": [
+ {
+ "chroot": {
+ "comps": null,
+ "comps_len": 0,
+ "buildroot_pkgs": [],
+ "name": "fedora-19-x86_64",
+ "comps_name": null
+ }
+ "_links": {}
+ },
+ { }
+ ],
+ "project_builds": [
+ {
+ "_links": { },
+ "build": {
+ "enable_net": true,
+ "submitted_on": 1422379448,
+ "repos": [],
+ "results": "https://copr-be.cloud.fedoraproject.org/results/jmiahman/Synergy-Linux/",
+ "started_on": 1422379466,
+ "source_type": 1,
+ "state": "succeeded",
+ "source_json": "{\"url\": \"http://dl.kororaproject.org/pub/korora/releases/21/source/korora-welcome-..."}",
+ "ended_on": 1422379584,
+ "timeout": 21600,
+ "pkg_version": "21.6-1.fc21",
+ "id": 69493
+ }
+ },
+ { }
+ ],
+ "_links": {
+ "self": {
+ "href": "/api_2/projects/2482?show_builds=True&show_chroots=True"
+ },
+ "chroots": {
+ "href": "/api_2/projects/2482/chroots"
+ },
+ "builds": {
+ "href": "/api_2/builds?project_id=2482"
+ }
+ }
+ }
+
+
+
+
diff --git a/backend/docs/source/conf.py b/frontend/docs/api_2/source/conf.py
similarity index 80%
copy from backend/docs/source/conf.py
copy to frontend/docs/api_2/source/conf.py
index fbfe196..9c4d89d 100644
--- a/backend/docs/source/conf.py
+++ b/frontend/docs/api_2/source/conf.py
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
#
-# copr-backend documentation build configuration file, created by
-# sphinx-quickstart on Tue Dec 2 15:51:01 2014.
+# Copr Api 2 documentation build configuration file, created by
+# sphinx-quickstart on Wed Sep 2 14:50:00 2015.
#
-# This file is execfile()d with the current directory set to its containing dir.
+# This file is execfile()d with the current directory set to its
+# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
@@ -13,43 +14,27 @@
import sys
import os
-from subprocess import call
-
-TO_INSTALL = [
- # "redis",
- "retask",
- "ansible",
-]
-
-
-on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
-if on_rtd:
- for pkg in TO_INSTALL:
- print(call(["pip", "install", "--upgrade", pkg]))
-
- print(call("python ../../../python/setup.py install".split()))
-
-# else:
-# # html_theme = 'nature'
-# pass
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
-sys.path.insert(0, os.path.abspath('../..'))
-sys.path.append(os.path.abspath('../../../python/'))
+#sys.path.insert(0, os.path.abspath('.'))
-
-# -- General configuration -----------------------------------------------------
+# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage',
- 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
-# extensions += ['sphinxarg.ext']
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+ 'sphinx.ext.intersphinx',
+ 'sphinx.ext.ifconfig',
+ 'sphinx.ext.viewcode',
+ 'sphinxcontrib.httpdomain',
+]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -64,17 +49,17 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
-project = u'copr-backend'
-copyright = u'2014, Copr dev team'
+project = u'Copr Api 2'
+copyright = u'2015, https://fedorahosted.org/copr/'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
-version = '0.61'
+version = '0.1'
# The full version, including alpha/beta/rc tags.
-release = version
+release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -90,7 +75,8 @@ release = version
# directories to ignore when looking for source files.
exclude_patterns = []
-# The reST default role (used for this markup: `text`) to use for all documents.
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
@@ -110,8 +96,11 @@ pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
-# -- Options for HTML output ---------------------------------------------------
+# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
@@ -146,6 +135,11 @@ html_theme = 'default'
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
@@ -188,10 +182,10 @@ html_static_path = ['_static']
#html_file_suffix = None
# Output file base name for HTML help builder.
-htmlhelp_basename = 'copr-backenddoc'
+htmlhelp_basename = 'CoprApi2doc'
-# -- Options for LaTeX output --------------------------------------------------
+# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
@@ -205,10 +199,11 @@ latex_elements = {
}
# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
latex_documents = [
- ('index', 'copr-backend.tex', u'copr-backend Documentation',
- u'Copr dev team', 'manual'),
+ ('index', 'CoprApi2.tex', u'Copr Api 2 Documentation',
+ u'https://fedorahosted.org/copr/', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -232,27 +227,27 @@ latex_documents = [
#latex_domain_indices = True
-# -- Options for manual page output --------------------------------------------
+# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- ('index', 'copr-backend', u'copr-backend Documentation',
- [u'Copr dev team'], 1)
+ ('index', 'coprapi2', u'Copr Api 2 Documentation',
+ [u'https://fedorahosted.org/copr/'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
-# -- Options for Texinfo output ------------------------------------------------
+# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'copr-backend', u'copr-backend Documentation',
- u'Copr dev team', 'copr-backend', 'One line description of project.',
+ ('index', 'CoprApi2', u'Copr Api 2 Documentation',
+ u'https://fedorahosted.org/copr/', 'CoprApi2', 'One line description of project.',
'Miscellaneous'),
]
@@ -265,14 +260,9 @@ texinfo_documents = [
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
-# ---
-# enabling __init__ for automodule
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
-autodoc_member_order = "bysource"
-autodoc_default_flags = [
- 'members',
- 'undoc-members',
- 'private-members',
- # 'special-members',
- # 'inherited-members'
-]
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
diff --git a/frontend/docs/api_2/source/index.rst b/frontend/docs/api_2/source/index.rst
new file mode 100644
index 0000000..093433d
--- /dev/null
+++ b/frontend/docs/api_2/source/index.rst
@@ -0,0 +1,63 @@
+.. Copr Api 2 documentation master file, created by
+ sphinx-quickstart on Wed Sep 2 14:50:00 2015.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to Copr Api 2's documentation!
+======================================
+
+Welcome to the documentation of the new REST-like API for the Copr build service.
+Almost all API calls is done using ``application/json`` ContentType.
+
+Endpoint of the the API is ``/api_2``, public data is available without authorization.
+
+To create new projects, submit builds and do other modification requests you will need to provide API token using
+BasicAuth_ . Token can be obtained and renewed at the CoprAPI_ page.
+
+This API implements HETEOAS_ in the very simple form: each entity is accompanied with set of relative links
+to other related entities. HETEOAS makes API self discoverable, so you shouldn't learn how to access sub-resources.
+Here is a short example with the content of API root:
+
+**GET /api_2**
+
+.. code-block:: javascript
+
+ {
+ "_links": {
+ "mock_chroots": {
+ "href": "/api_2/mock_chroots"
+ },
+ "self": {
+ "href": "/api_2/"
+ },
+ "projects": {
+ "href": "/api_2/projects"
+ },
+ "builds": {
+ "href": "/api_2/builds"
+ }
+ }
+
+Errors
+______
+todo:
+
+
+Resources
+---------
+.. toctree::
+ :maxdepth: 1
+
+ Resources/project
+
+
+.. Indices and tables
+ ==================
+ * :ref:`genindex`
+ * :ref:`modindex`
+ * :ref:`search`
+
+.. _BasicAuth: https://en.wikipedia.org/wiki/Basic_access_authentication
+.. _CoprAPI: https://copr.fedoraproject.org/api
+.. _HETEOAS: https://en.wikipedia.org/wiki/HATEOAS
+
8 years, 8 months
[copr] master: enable tests again (98dcfab)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 98dcfab80b676f6be388db662d014f0801bb8ef0
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Wed Sep 2 16:17:42 2015 +0200
enable tests again
>---------------------------------------------------------------
frontend/copr-frontend.spec | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/frontend/copr-frontend.spec b/frontend/copr-frontend.spec
index 0dc322a..3377f4a 100644
--- a/frontend/copr-frontend.spec
+++ b/frontend/copr-frontend.spec
@@ -151,7 +151,7 @@ touch %{buildroot}%{_var}/log/copr/frontend.log
%if %{with_test} && "%{_arch}" == "x86_64"
pushd coprs_frontend
rm -rf /tmp/copr.db /tmp/whooshee || :
- #COPR_CONFIG="$(pwd)/config/copr_unit_test.conf" ./manage.py test
+ COPR_CONFIG="$(pwd)/config/copr_unit_test.conf" ./manage.py test
popd
%endif
8 years, 8 months
[copr] master: [frontend] [dist-git] provide build failure details (117db82)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 117db82f93be38dc3db8930049bf424df1100705
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Mon Aug 31 17:56:08 2015 +0200
[frontend] [dist-git] provide build failure details
>---------------------------------------------------------------
dist-git/dist_git/dist_git_importer.py | 14 ++++++++++--
.../{5845661bb37d_foo.py => 3b4cfc666d14_.py} | 16 +++++++-------
frontend/coprs_frontend/coprs/helpers.py | 10 +++++++++
frontend/coprs_frontend/coprs/models.py | 6 +++++
.../templates/coprs/detail/_describe_failure.html | 21 ++++++++++++++++++++
.../coprs/templates/coprs/detail/build.html | 4 ++-
.../coprs/views/backend_ns/backend_general.py | 7 ++++++
7 files changed, 66 insertions(+), 12 deletions(-)
diff --git a/dist-git/dist_git/dist_git_importer.py b/dist-git/dist_git/dist_git_importer.py
index 701e030..4bdcca9 100755
--- a/dist-git/dist_git/dist_git_importer.py
+++ b/dist-git/dist_git/dist_git_importer.py
@@ -236,13 +236,21 @@ class DistGitImporter(object):
log.debug("sending a response - success")
self.post_back(task.get_dict_for_frontend())
- except (PackageImportException, PackageDownloadException, PackageQueryException):
+ except PackageImportException:
log.exception("send a response - failure during import of: {}".format(task.package_url))
- self.post_back_safe({"task_id": task.task_id, "error": "error"})
+ self.post_back_safe({"task_id": task.task_id, "error": "git_import_failed"})
+
+ except PackageDownloadException:
+ log.exception("send a response - failure during download of: {}".format(task.package_url))
+ self.post_back_safe({"task_id": task.task_id, "error": "srpm_download_failed"})
+
+ except PackageQueryException:
+ log.exception("send a response - failure during query of: {}".format(task.package_url))
+ self.post_back_safe({"task_id": task.task_id, "error": "srpm_query_failed"})
except Exception:
log.exception("Unexpected error during package import")
- self.post_back_safe({"task_id": task.task_id, "error": "error"})
+ self.post_back_safe({"task_id": task.task_id, "error": "unknown_error"})
finally:
shutil.rmtree(tmp_root, ignore_errors=True)
diff --git a/frontend/coprs_frontend/alembic/versions/5845661bb37d_foo.py b/frontend/coprs_frontend/alembic/versions/3b4cfc666d14_.py
similarity index 52%
copy from frontend/coprs_frontend/alembic/versions/5845661bb37d_foo.py
copy to frontend/coprs_frontend/alembic/versions/3b4cfc666d14_.py
index f37869f..b58e0d2 100644
--- a/frontend/coprs_frontend/alembic/versions/5845661bb37d_foo.py
+++ b/frontend/coprs_frontend/alembic/versions/3b4cfc666d14_.py
@@ -1,14 +1,14 @@
-"""add playgroung column
+"""empty message
-Revision ID: 5845661bb37d
-Revises: 498884ac47db
-Create Date: 2014-04-04 11:25:36.216132
+Revision ID: 3b4cfc666d14
+Revises: 22fde92cb568
+Create Date: 2015-08-31 17:17:52.396183
"""
# revision identifiers, used by Alembic.
-revision = '5845661bb37d'
-down_revision = '498884ac47db'
+revision = '3b4cfc666d14'
+down_revision = '22fde92cb568'
from alembic import op
import sqlalchemy as sa
@@ -16,11 +16,11 @@ import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
- op.add_column('copr', sa.Column('playground', sa.Boolean(), nullable=True))
+ op.add_column('build', sa.Column('fail_type', sa.Integer(), default=0))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
- op.drop_column('copr', 'playground')
+ op.drop_column('build', 'fail_type')
### end Alembic commands ###
diff --git a/frontend/coprs_frontend/coprs/helpers.py b/frontend/coprs_frontend/coprs/helpers.py
index 7d253af..f3406b4 100644
--- a/frontend/coprs_frontend/coprs/helpers.py
+++ b/frontend/coprs_frontend/coprs/helpers.py
@@ -97,6 +97,16 @@ class BuildSourceEnum(object):
"srpm_upload": 2} # pkg, tmp
+class FailTypeEnum(object):
+ __metaclass__ = EnumType
+ vals = {"unset": 0,
+ "unknown_error": 1,
+ "build_error": 2,
+ "git_import_failed": 3,
+ "srpm_download_failed": 4,
+ "srpm_query_failed": 5}
+
+
class Paginator(object):
def __init__(self, query, total_count, page=1,
diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py
index 00a3a32..b6044e9 100644
--- a/frontend/coprs_frontend/coprs/models.py
+++ b/frontend/coprs_frontend/coprs/models.py
@@ -349,6 +349,8 @@ class Build(db.Model, helpers.Serializer):
source_type = db.Column(db.Integer, default=helpers.BuildSourceEnum("unset"))
# Source of the build: description in json, example: git link, srpm url, etc.
source_json = db.Column(db.Text)
+ # Type of failure: type identifier
+ fail_type = db.Column(db.Integer, default=helpers.FailTypeEnum("unset"))
# relations
user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
@@ -361,6 +363,10 @@ class Build(db.Model, helpers.Serializer):
chroots = association_proxy("build_chroots", "mock_chroot")
@property
+ def fail_type_test(self):
+ return helpers.FailTypeEnum(self.fail_type)
+
+ @property
def is_older_results_naming_used(self):
# we have changed result directory naming together with transition to dist-git
# that's why we use so strange criterion
diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/_describe_failure.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/_describe_failure.html
new file mode 100644
index 0000000..f8dfefe
--- /dev/null
+++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/_describe_failure.html
@@ -0,0 +1,21 @@
+{% macro describe_failure(build) %}
+{% if build.fail_type %}
+ <dt>Build State:</dt>
+ <dd><span class="build-failed">failed</span></dd>
+
+ <dt>State Description:</dt>
+ <dd>
+ {% if build.fail_type_text == "unknown_error" %}
+ Unknown error.
+ {% elif build.fail_type_text == "build_error" %}
+ Build error. See logs of individual chroots for more information.
+ {% elif build.fail_type_text == "git_import_failed" %}
+ Importing SRPM into Dist Git failed.
+ {% elif build.fail_type_text == "srpm_download_failed" %}
+ Could not download the SRPM. Probably bad URL.
+ {% elif build.fail_type_text == "srpm_query_failed" %}
+ RPM query failed. The file is probably not a SRPM.
+ {% endif %}
+ </dd>
+{% endif %}
+{% endmacro %}
diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
index 68e65f2..171f4a0 100644
--- a/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
+++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
@@ -1,6 +1,7 @@
{% extends "coprs/detail.html" %}
{% from "coprs/detail/_builds_forms.html" import copr_build_cancel_form, copr_build_repeat_form, copr_build_delete_form %}
{% from "coprs/detail/_describe_source.html" import describe_source %}
+{% from "coprs/detail/_describe_failure.html" import describe_failure %}
{% from "_helpers.html" import chroot_to_os_logo %}
{% block title %}Build {{ build.id }} in {{ build.copr.owner.name }}/{{ build.copr.name }}{% endblock %}
{%block project_breadcrumb %}
@@ -90,7 +91,8 @@
<h3> Build Results </h3>
<dl class="dl-horizontal">
- <dt> Built Packages:</dt>
+ {{ describe_failure(build) }}
+ <dt> Built Packages:</dt>
{% if build.built_packages %}
{% for pkg in build.built_packages.split("\n"): %}
<dd>{{ pkg }}</dd>
diff --git a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
index bfd22da..64b30d7 100644
--- a/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
+++ b/frontend/coprs_frontend/coprs/views/backend_ns/backend_general.py
@@ -88,6 +88,13 @@ def dist_git_upload_completed():
# Failed?
elif "error" in flask.request.json:
+ error_type = flask.request.json["error"]
+
+ try:
+ build.fail_type = helpers.FailTypeEnum(error_type)
+ except KeyError:
+ build.fail_type = helpers.FailTypeEnum("unknown_error")
+
for ch in build_chroots:
ch.status = helpers.StatusEnum("failed")
8 years, 8 months
[copr] master: typo (d79a7fa)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit d79a7fa33ba96e34e45078ffeaf3d3a23393a311
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Wed Sep 2 16:17:15 2015 +0200
typo
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/models.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py
index b6044e9..945d9e2 100644
--- a/frontend/coprs_frontend/coprs/models.py
+++ b/frontend/coprs_frontend/coprs/models.py
@@ -363,7 +363,7 @@ class Build(db.Model, helpers.Serializer):
chroots = association_proxy("build_chroots", "mock_chroot")
@property
- def fail_type_test(self):
+ def fail_type_text(self):
return helpers.FailTypeEnum(self.fail_type)
@property
8 years, 8 months
[copr] master: [frontend] UI fix (dca1a94)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit dca1a94b1a50a759f936799d0edf5e75d9f8213f
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Mon Aug 31 14:44:04 2015 +0200
[frontend] UI fix
>---------------------------------------------------------------
.../coprs/templates/coprs/detail/build.html | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
index 55a826b..68e65f2 100644
--- a/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
+++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
@@ -19,7 +19,7 @@
<p> You can go to <a href="{{url_for("coprs_ns.copr_build", username = build.copr.owner.name, coprname = build.copr.name, build_id = build.id)}}"> {{ build.copr.owner.name }}/{{ build.copr.name }}/build/{{build.id}} </a>to see this build. </p>
{% else %}
-<h2> Build {{ build.id }}: <span class="build-{{build.state}}"> {{ build.state }} </span> </h2>
+<h2>Build {{ build.id }}: <span class="build-{{build.state}}"> {{ build.state }} </span> </h2>
<div class="row">
<div class="col-sm-8 col-md-9">
@@ -182,8 +182,8 @@
</tbody>
</table>
-
</div>
+</div>
{% endif %}
8 years, 8 months
[copr] master: [frontend] disable documentation (7558f6f)
by asamalik@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 7558f6fabf401cfc9869a924a381c2a8678e5116
Author: Adam Samalik <asamalik(a)redhat.com>
Date: Wed Sep 2 13:56:36 2015 +0200
[frontend] disable documentation
>---------------------------------------------------------------
frontend/copr-frontend.spec | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/frontend/copr-frontend.spec b/frontend/copr-frontend.spec
index 4a6b670..0dc322a 100644
--- a/frontend/copr-frontend.spec
+++ b/frontend/copr-frontend.spec
@@ -19,8 +19,8 @@ URL: https://fedorahosted.org/copr/
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
-BuildRequires: asciidoc
-BuildRequires: libxslt
+#BuildRequires: asciidoc
+#BuildRequires: libxslt
BuildRequires: util-linux
BuildRequires: python-setuptools
BuildRequires: python-requests
@@ -30,8 +30,8 @@ BuildRequires: systemd
BuildRequires: python-argparse
%endif
#for doc package
-BuildRequires: epydoc
-BuildRequires: graphviz
+#BuildRequires: epydoc
+#BuildRequires: graphviz
Requires: httpd
Requires: mod_wsgi
@@ -113,9 +113,9 @@ only.
%build
# build documentation
-pushd documentation
-make %{?_smp_mflags} python
-popd
+#pushd documentation
+#make %{?_smp_mflags} python
+#popd
%install
@@ -151,7 +151,7 @@ touch %{buildroot}%{_var}/log/copr/frontend.log
%if %{with_test} && "%{_arch}" == "x86_64"
pushd coprs_frontend
rm -rf /tmp/copr.db /tmp/whooshee || :
- COPR_CONFIG="$(pwd)/config/copr_unit_test.conf" ./manage.py test
+ #COPR_CONFIG="$(pwd)/config/copr_unit_test.conf" ./manage.py test
popd
%endif
@@ -196,7 +196,7 @@ service logstash condrestart
%files doc
%license LICENSE
-%doc documentation/python-doc
+#%doc documentation/python-doc
%changelog
* Tue Aug 11 2015 Miroslav Suchý <msuchy(a)redhat.com> 1.66-1
8 years, 8 months
[copr] master: [python] add run_tests.sh script (ec6812b)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit ec6812b5ce035ca31f7bcaa09e6b19b1c704d2a9
Author: Jakub Kadlčík <jkadlcik(a)redhat.com>
Date: Wed Sep 2 14:29:57 2015 +0200
[python] add run_tests.sh script
>---------------------------------------------------------------
python/run_tests.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/python/run_tests.sh b/python/run_tests.sh
new file mode 100755
index 0000000..b2f6501
--- /dev/null
+++ b/python/run_tests.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+#python -B -m pytest --cov-report term-missing --cov ./copr_cli/ tests $@
+
+python -B -m pytest --cov-report term-missing --cov ./copr/test -s $@
8 years, 8 months
[copr] master: [python] fix unicode representation of CoprResponse (RhBug:1258915) (59288d7)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 59288d786fafc6623a0aeeffb96516128384f721
Author: Jakub Kadlčík <jkadlcik(a)redhat.com>
Date: Wed Sep 2 14:14:37 2015 +0200
[python] fix unicode representation of CoprResponse (RhBug:1258915)
>---------------------------------------------------------------
python/copr/client/responses.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/copr/client/responses.py b/python/copr/client/responses.py
index 4911f36..af46f58 100644
--- a/python/copr/client/responses.py
+++ b/python/copr/client/responses.py
@@ -62,7 +62,7 @@ class CoprResponse(UnicodeMixin):
raise KeyError(str(item))
def __unicode__(self):
- return self.data
+ return str(self.data)
class BaseHandle(object):
8 years, 8 months
[copr] master: [frontend][api] Updated and test creation of the new Projects (POST to /projects) (360c3a6)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 360c3a6beea130daab69896e033938a638763362
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Tue Sep 1 16:18:27 2015 +0200
[frontend][api] Updated and test creation of the new Projects (POST to /projects)
>---------------------------------------------------------------
.../coprs/rest_api/resources/project.py | 2 -
frontend/coprs_frontend/coprs/rest_api/schemas.py | 12 ++-
.../tests/test_api/test_project_r.py | 119 ++++++++++++++++++--
.../tests/test_logic/test_coprs_logic.py | 8 --
4 files changed, 117 insertions(+), 24 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/project.py b/frontend/coprs_frontend/coprs/rest_api/resources/project.py
index ede6fc2..d0b989f 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/project.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/project.py
@@ -29,10 +29,8 @@ class ProjectListR(Resource):
Creates new copr
"""
owner = flask.g.user
-
result = mm_deserialize(ProjectCreateSchema(), flask.request.data)
- # todo check that chroots are available
req = result.data
name = req.pop("name")
selected_chroots = req.pop("chroots")
diff --git a/frontend/coprs_frontend/coprs/rest_api/schemas.py b/frontend/coprs_frontend/coprs/rest_api/schemas.py
index 216a880..cc2b446 100644
--- a/frontend/coprs_frontend/coprs/rest_api/schemas.py
+++ b/frontend/coprs_frontend/coprs/rest_api/schemas.py
@@ -79,8 +79,16 @@ class ProjectSchema(Schema):
class ProjectCreateSchema(ProjectSchema):
- name = fields.Str(required=True)
- chroots = fields.List(fields.Str(), load_only=True)
+ name = fields.Str(
+ required=True,
+ validate=[
+ validate.Regexp(
+ r"^[a-zA-Z][\w.-]*$",
+ error="Name must contain only letters,"
+ "digits, underscores, dashes and dots."
+ "And starts with letter"),
+ ])
+ chroots = SpaceSeparatedList(load_only=True, default=list)
class CoprChrootSchema(Schema):
diff --git a/frontend/coprs_frontend/tests/test_api/test_project_r.py b/frontend/coprs_frontend/tests/test_api/test_project_r.py
index c6bb38d..316a6b7 100644
--- a/frontend/coprs_frontend/tests/test_api/test_project_r.py
+++ b/frontend/coprs_frontend/tests/test_api/test_project_r.py
@@ -30,14 +30,18 @@ class TestProjectResource(CoprsTestCase):
"contact": "foo(a)example.com",
}
- def test_self(self):
+ def test_project_list_self(self):
href = "/api_2/projects"
r = self.tc.get(href)
assert r.status_code == 200
obj = json.loads(r.data)
assert obj["_links"]["self"]["href"] == href
- def test_create_new(self, f_users, f_mock_chroots, f_users_api):
+ # test_project_list_all
+ # test_project_list_by_name
+ # test_project_list_by_user
+
+ def test_project_create_new(self, f_users, f_mock_chroots, f_users_api):
self.db.session.add_all([self.u1, self.mc1])
self.db.session.commit()
@@ -47,7 +51,7 @@ class TestProjectResource(CoprsTestCase):
"chroots": [
chroot_name,
],
- "additional_repos": ["copr://bar/zar", ]
+ "repos": ["copr://bar/zar", ]
}
r = self.request_rest_api_with_auth(
@@ -61,11 +65,102 @@ class TestProjectResource(CoprsTestCase):
assert len(copr_chroots_dict["chroots"]) == 1
assert copr_chroots_dict["chroots"][0]["chroot"]["name"] == chroot_name
- def test_get_one_not_found(self, f_users, f_mock_chroots, f_db):
+ def test_project_create_bad_values(
+ self, f_users, f_mock_chroots,
+ f_users_api, f_db):
+
+ href = "/api_2/projects"
+ cases = []
+
+ def add_case(field, value):
+ t = copy.deepcopy(self.put_update_dict)
+
+ t["name"] = "foobar_fake"
+ t["chroots"] = [mc.name for mc in self.mc_basic_list]
+
+ t[field] = value
+ cases.append(t)
+
+ add_case("repos", "foobar")
+ add_case("repos", 1)
+ add_case("contact", "adsg")
+ add_case("contact", "1")
+ add_case("homepage", "sdg")
+
+ add_case("name", None)
+ add_case("name", "")
+ add_case("name", "3abc")
+ add_case("chroots", "sdg")
+ add_case("chroots", "")
+
+ for test_case in cases:
+ r0 = self.request_rest_api_with_auth(
+ href,
+ method="post",
+ content=test_case
+ )
+ assert r0.status_code == 400
+
+ def test_project_create_ok_values(
+ self, f_users, f_mock_chroots,
+ f_users_api, f_db):
+
+ href = "/api_2/projects"
+ cases = []
+
+ self.counter = 0
+
+ def add_case(field, value):
+ t = copy.deepcopy(self.put_update_dict)
+ t["name"] = "foobar_{}".format(self.counter)
+ t["chroots"] = [mc.name for mc in self.mc_basic_list]
+ self.counter += 1
+
+ t[field] = value
+ cases.append(t)
+
+ add_case("repos", [])
+ add_case("repos", None)
+ add_case("contact", "")
+ add_case("contact", None)
+ add_case("contact", "foo(a)bar.com")
+ add_case("homepage", "http://foo.org/bar/xdeeg?sdfg")
+
+ add_case("name", "asdas-asdf")
+ add_case("name", "a2222222")
+ add_case("chroots", [])
+
+ for test_case in cases:
+ r0 = self.request_rest_api_with_auth(
+ href,
+ method="post",
+ content=test_case
+ )
+ assert r0.status_code == 201
+
+ def test_project_create_new_project_exists(
+ self, f_users, f_mock_chroots, f_coprs, f_users_api):
+ self.db.session.add_all([self.u1, self.mc1])
+ self.db.session.commit()
+
+ chroot_name = self.mc1.name
+ body = {
+ "name": self.c1.name,
+ "chroots": [
+ chroot_name,
+ ],
+ "repos": ["copr://bar/zar", ]
+ }
+ r = self.request_rest_api_with_auth(
+ "/api_2/projects",
+ content=body, method="post")
+ assert r.status_code == 409
+
+ def test_project_get_one_not_found(self, f_users, f_mock_chroots, f_db):
r = self.tc.get("/api_2/projects/1")
assert r.status_code == 404
- def test_get_one(self, f_users, f_mock_chroots, f_coprs, f_db):
+ def test_project_get_one(self, f_users, f_mock_chroots, f_coprs, f_db):
p_id_list = [p.id for p in self.basic_coprs_list]
for p_id in p_id_list:
@@ -77,7 +172,7 @@ class TestProjectResource(CoprsTestCase):
assert obj["project"]["id"] == p_id
assert obj["_links"]["self"]["href"] == href
- def test_get_one_with_chroots(self, f_users, f_mock_chroots, f_coprs, f_db):
+ def test_project_get_one_with_chroots(self, f_users, f_mock_chroots, f_coprs, f_db):
p_id_list = [p.id for p in self.basic_coprs_list]
for p_id in p_id_list:
@@ -91,7 +186,7 @@ class TestProjectResource(CoprsTestCase):
project = CoprsLogic.get_by_id(p_id).one()
assert len(obj["project_chroots"]) == len(project.copr_chroots)
- def test_get_one_with_builds(
+ def test_project_get_one_with_builds(
self, f_users, f_mock_chroots,
f_coprs, f_builds, f_db):
@@ -108,7 +203,7 @@ class TestProjectResource(CoprsTestCase):
builds = BuildsLogic.get_multiple_by_copr(project).all()
assert len(obj["project_builds"]) == len(builds)
- def test_delete_not_found(
+ def test_project_delete_not_found(
self, f_users, f_mock_chroots,
f_users_api, f_db):
@@ -120,7 +215,7 @@ class TestProjectResource(CoprsTestCase):
)
assert r0.status_code == 404
- def test_delete_ok(
+ def test_project_delete_ok(
self, f_users, f_mock_chroots,
f_coprs, f_users_api, f_db):
@@ -133,7 +228,7 @@ class TestProjectResource(CoprsTestCase):
assert r0.status_code == 204
assert self.tc.get(href).status_code == 404
- def test_delete_fail_unfinished_build(
+ def test_project_delete_fail_unfinished_build(
self, f_users, f_mock_chroots,
f_coprs, f_builds, f_users_api, f_db):
@@ -145,7 +240,7 @@ class TestProjectResource(CoprsTestCase):
)
assert r0.status_code == 400
- def test_delete_fail_unfinished_project_action(
+ def test_project_delete_fail_unfinished_project_action(
self, f_users, f_mock_chroots,
f_coprs, f_users_api, f_db):
@@ -158,7 +253,7 @@ class TestProjectResource(CoprsTestCase):
)
assert r0.status_code == 400
- def test_delete_wrong_user(
+ def test_project_delete_wrong_user(
self, f_users, f_mock_chroots,
f_coprs, f_users_api, f_db):
diff --git a/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py b/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
index 9c68f56..38e1cbf 100644
--- a/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
+++ b/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
@@ -10,14 +10,6 @@ from tests.coprs_test_case import CoprsTestCase
class TestCoprsLogic(CoprsTestCase):
- def test_update_raises_if_copr_has_unfinished_actions(self, f_users,
- f_coprs, f_actions,
- f_db):
- self.c1.name = "foo"
- with pytest.raises(ActionInProgressException):
- CoprsLogic.update(self.u1, self.c1)
- self.db.session.rollback()
-
def test_legal_flag_doesnt_block_copr_functionality(self, f_users,
f_coprs, f_db):
self.db.session.add(self.models.Action(
8 years, 8 months
[copr] master: [frontend][api] minor fixes (7de78fc)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 7de78fc54ed0b9bed0bedc6f969c4f108d3d25b7
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Tue Sep 1 16:28:19 2015 +0200
[frontend][api] minor fixes
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/logic/coprs_logic.py | 4 +++-
.../coprs/rest_api/resources/project_chroot.py | 6 +++---
.../tests/test_api/test_project_chroot_r.py | 20 ++++++++++++++++++--
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/logic/coprs_logic.py b/frontend/coprs_frontend/coprs/logic/coprs_logic.py
index 91206cc..d5c8725 100644
--- a/frontend/coprs_frontend/coprs/logic/coprs_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/coprs_logic.py
@@ -377,11 +377,13 @@ class CoprChrootsLogic(object):
@classmethod
def create_chroot(cls, user, copr, mock_chroot,
- buildroot_pkgs, comps=None, comps_name=None):
+ buildroot_pkgs=None, comps=None, comps_name=None):
"""
:type user: models.User
:type mock_chroot: models.MockChroot
"""
+ if buildroot_pkgs is None:
+ buildroot_pkgs = ""
UsersLogic.raise_if_cant_update_copr(
user, copr,
"Only owners and admins may update their projects.")
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 d9043a7..294114c 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/project_chroot.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/project_chroot.py
@@ -15,7 +15,7 @@ from ...logic.coprs_logic import MockChrootsLogic, CoprChrootsLogic, CoprsLogic
from ...exceptions import InsufficientRightsException, MalformedArgumentException
from ..exceptions import AccessForbidden, MalformedRequest, \
- ObjectAlreadyExists, ServerError
+ ObjectAlreadyExists, ServerError, ObjectNotFoundError
from ..common import rest_api_auth_required, render_copr_chroot
from ..schemas import CoprChrootSchema, CoprChrootCreateSchema
from ..util import get_one_safe, mm_deserialize
@@ -48,8 +48,8 @@ class ProjectChrootListR(Resource):
try:
mock_chroot = get_one_safe(MockChrootsLogic.get_from_name(name))
- except MalformedArgumentException as err:
- raise MalformedRequest("Bad mock chroot name: {}".format(err))
+ except (MalformedArgumentException, ObjectNotFoundError) as err:
+ raise MalformedRequest("Bad mock chroot name: {}. Error: {}".format(name, err))
if mock_chroot is None:
raise MalformedRequest("Mock chroot `{}` doesn't exists"
diff --git a/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py b/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
index 3f84822..fef831d 100644
--- a/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
+++ b/frontend/coprs_frontend/tests/test_api/test_project_chroot_r.py
@@ -215,6 +215,23 @@ class TestProjectChrootResource(CoprsTestCase):
assert_content(json.loads(r3.data)["chroot"])
+ def test_create_chroot_build_no_buildchroot(self, f_users, f_coprs, f_db, f_users_api, f_mock_chroots):
+ new_chroot_name = self.mc2.name
+
+ base_data = {
+ "comps": "<comps><group></group></comps>",
+ "comps_name": "test.xml",
+ }
+ data = {
+ "name": new_chroot_name,
+ }
+ data.update(base_data)
+ self.db.session.commit()
+
+ r0 = self.tc.get("/api_2/projects/1/chroots")
+ assert r0.status_code == 200
+ assert len(json.loads(r0.data)["chroots"]) == 1
+
def test_create_chroot_missing_name(self, f_users, f_coprs, f_db, f_users_api, f_mock_chroots):
base_data = {
"buildroot_pkgs": ["foo", "bar"],
@@ -240,7 +257,7 @@ class TestProjectChrootResource(CoprsTestCase):
def test_create_chroot_non_existing_name(
self, f_users, f_coprs, f_db, f_users_api, f_mock_chroots):
- new_chroot_name = "completely_fake_chroot"
+ new_chroot_name = "completely-fake-chroot"
base_data = {
"buildroot_pkgs": ["foo", "bar"],
"comps": "<comps><group></group></comps>",
@@ -251,7 +268,6 @@ class TestProjectChrootResource(CoprsTestCase):
}
data.update(base_data)
self.db.session.commit()
- self.db.session.commit()
r0 = self.tc.get("/api_2/projects/1/chroots")
assert r0.status_code == 200
assert len(json.loads(r0.data)["chroots"]) == 1
8 years, 8 months