summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ick2/__init__.py1
-rw-r--r--ick2/buildsapi.py38
-rw-r--r--ick2/controllerapi.py24
-rw-r--r--without-tests1
4 files changed, 41 insertions, 23 deletions
diff --git a/ick2/__init__.py b/ick2/__init__.py
index 4321f67..3ed21c8 100644
--- a/ick2/__init__.py
+++ b/ick2/__init__.py
@@ -29,6 +29,7 @@ from .responses import (
text_plain,
)
from .apibase import APIbase, ResourceApiBase
+from .buildsapi import BuildsAPI
from .versionapi import VersionAPI
from .workerapi import WorkerAPI
from .controllerapi import (
diff --git a/ick2/buildsapi.py b/ick2/buildsapi.py
new file mode 100644
index 0000000..2d5b5f9
--- /dev/null
+++ b/ick2/buildsapi.py
@@ -0,0 +1,38 @@
+# Copyright (C) 2017 Lars Wirzenius
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import ick2
+
+
+class BuildsAPI(ick2.ResourceApiBase): # pragma: no cover
+
+ def __init__(self, state):
+ super().__init__('builds', state)
+
+ def get_resource_name(self, resource):
+ return resource['build']
+
+ def create(self, body): # pragma: no cover
+ raise ick2.MethodNotAllowed('Creating builds directly is not allowed')
+
+ def update(self, body, name): # pragma: no cover
+ raise ick2.MethodNotAllowed('Updating builds directly is not allowed')
+
+ def list(self):
+ result = super().list()
+ items = result[self._type_name]
+ items.sort(key=lambda x: x.get('build_id'))
+ result[self._type_name] = items
+ return result
diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py
index 62b7056..433d3d0 100644
--- a/ick2/controllerapi.py
+++ b/ick2/controllerapi.py
@@ -30,7 +30,7 @@ class ControllerAPI:
def find_missing_route(self, missing_path): # pragma: no cover
apis = {
'/version': ick2.VersionAPI,
- '/builds': BuildsAPI,
+ '/builds': ick2.BuildsAPI,
'/logs': LogAPI,
'/projects': ProjectAPI,
'/work': WorkAPI,
@@ -46,28 +46,6 @@ class ControllerAPI:
return routes
-class BuildsAPI(ick2.ResourceApiBase): # pragma: no cover
-
- def __init__(self, state):
- super().__init__('builds', state)
-
- def get_resource_name(self, resource):
- return resource['build']
-
- def create(self, body): # pragma: no cover
- raise ick2.MethodNotAllowed('Creating builds directly is not allowed')
-
- def update(self, body, name): # pragma: no cover
- raise ick2.MethodNotAllowed('Updating builds directly is not allowed')
-
- def list(self):
- result = super().list()
- items = result[self._type_name]
- items.sort(key=lambda x: x.get('build_id'))
- result[self._type_name] = items
- return result
-
-
class LogAPI(ick2.ResourceApiBase): # pragma: no cover
def __init__(self, state):
diff --git a/without-tests b/without-tests
index 097472c..6c767d5 100644
--- a/without-tests
+++ b/without-tests
@@ -1,5 +1,6 @@
ick2/__init__.py
ick2/apibase.py
+ick2/buildsapi.py
ick2/exceptions.py
ick2/logging.py
ick2/responses.py