diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-11-05 18:09:38 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-11-05 18:09:38 +0100 |
commit | 860bca1a4b14b8a8fbe4bc40f8680b63263b4aa0 (patch) | |
tree | 944e2c6e36766d9fb7020bc9cda43f34df605f9c /ick2 | |
parent | 23abcad05966d3fcf3009a594aef6aa2f193cffd (diff) | |
download | ick2-860bca1a4b14b8a8fbe4bc40f8680b63263b4aa0.tar.gz |
Add: start on WorkAPI
Diffstat (limited to 'ick2')
-rw-r--r-- | ick2/__init__.py | 2 | ||||
-rw-r--r-- | ick2/controllerapi.py | 26 | ||||
-rw-r--r-- | ick2/controllerapi_tests.py | 47 |
3 files changed, 75 insertions, 0 deletions
diff --git a/ick2/__init__.py b/ick2/__init__.py index 2827c03..02a8e76 100644 --- a/ick2/__init__.py +++ b/ick2/__init__.py @@ -20,4 +20,6 @@ from .controllerapi import ( ControllerAPI, ProjectAPI, VersionAPI, + WorkAPI, + WorkerAPI, ) diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py index 91368c1..9ac4bcc 100644 --- a/ick2/controllerapi.py +++ b/ick2/controllerapi.py @@ -297,6 +297,32 @@ class ProjectAPI(ResourceApiBase): } +class WorkAPI(APIbase): + + def __init__(self, state, projects, workers): + super().__init__(state) + self._projects = projects + self._workers = workers + + def get_work(self, worker): + return {} + + def create(self, *args, **kwargs): # pragma: no cover + pass + + def update(self, *args, **kwargs): # pragma: no cover + pass + + def list(self, *args, **kwargs): # pragma: no cover + pass + + def show(self, *args, **kwargs): # pragma: no cover + pass + + def delete(self, *args, **kwargs): # pragma: no cover + pass + + def response(status_code, body, headers): # pragma: no cover obj = { 'status': status_code, diff --git a/ick2/controllerapi_tests.py b/ick2/controllerapi_tests.py index 0c3f577..f3d0d08 100644 --- a/ick2/controllerapi_tests.py +++ b/ick2/controllerapi_tests.py @@ -229,3 +229,50 @@ class ProjectAPITests(unittest.TestCase): api.create(project) with self.assertRaises(ick2.NotFound): api.set_pipeline('idle', 'foo', 'build') + + +class WorkAPITests(unittest.TestCase): + + def setUp(self): + self.tempdir = tempfile.mkdtemp() + self.statedir = os.path.join(self.tempdir, 'state/dir') + self.state = ick2.ControllerState() + self.state.set_state_directory(self.statedir) + + def tearDown(self): + shutil.rmtree(self.tempdir) + + def create_project_api(self): + project = { + 'project': 'foo', + 'pipelines': [ + { + 'name': 'build', + 'actions': [ + { + 'shell': 'step-1', + }, + ], + }, + ], + } + api = ick2.ProjectAPI(self.state) + api.create(project) + return api + + def create_worker_api(self): + worker = { + 'worker': 'asterix', + } + api = ick2.WorkerAPI(self.state) + api.create(worker) + return api + + def create_work_api(self, projects, workers): + return ick2.WorkAPI(self.state, projects, workers) + + def test_worker_gets_no_work_when_no_pipeline_is_triggered(self): + projects = self.create_project_api() + workers = self.create_worker_api() + work = self.create_work_api(projects, workers) + self.assertEqual(work.get_work('asterix'), {}) |