From 4e45654544c65741de49f2929664de84a76712e0 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 18 Nov 2017 20:37:53 +0100 Subject: Refactor: move WorkerAPI to its own module --- ick2/__init__.py | 2 +- ick2/controllerapi.py | 11 +---------- ick2/workerapi.py | 25 +++++++++++++++++++++++++ without-tests | 3 +-- 4 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 ick2/workerapi.py diff --git a/ick2/__init__.py b/ick2/__init__.py index 0ba03c5..4321f67 100644 --- a/ick2/__init__.py +++ b/ick2/__init__.py @@ -30,9 +30,9 @@ from .responses import ( ) from .apibase import APIbase, ResourceApiBase from .versionapi import VersionAPI +from .workerapi import WorkerAPI from .controllerapi import ( ControllerAPI, ProjectAPI, WorkAPI, - WorkerAPI, ) diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py index 49c972b..62b7056 100644 --- a/ick2/controllerapi.py +++ b/ick2/controllerapi.py @@ -34,7 +34,7 @@ class ControllerAPI: '/logs': LogAPI, '/projects': ProjectAPI, '/work': WorkAPI, - '/workers': WorkerAPI, + '/workers': ick2.WorkerAPI, } routes = [] @@ -46,15 +46,6 @@ class ControllerAPI: return routes -class WorkerAPI(ick2.ResourceApiBase): # pragma: no cover - - def __init__(self, state): - super().__init__('workers', state) - - def get_resource_name(self, resource): - return resource['worker'] - - class BuildsAPI(ick2.ResourceApiBase): # pragma: no cover def __init__(self, state): diff --git a/ick2/workerapi.py b/ick2/workerapi.py new file mode 100644 index 0000000..5a7e835 --- /dev/null +++ b/ick2/workerapi.py @@ -0,0 +1,25 @@ +# 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 . + + +import ick2 + + +class WorkerAPI(ick2.ResourceApiBase): # pragma: no cover + + def __init__(self, state): + super().__init__('workers', state) + + def get_resource_name(self, resource): + return resource['worker'] diff --git a/without-tests b/without-tests index 099db74..097472c 100644 --- a/without-tests +++ b/without-tests @@ -5,5 +5,4 @@ ick2/logging.py ick2/responses.py ick2/version.py ick2/versionapi.py - - +ick2/workerapi.py -- cgit v1.2.1