diff options
Diffstat (limited to 'ick2/workapi_tests.py')
-rw-r--r-- | ick2/workapi_tests.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/ick2/workapi_tests.py b/ick2/workapi_tests.py index 0ac3a86..c368b4b 100644 --- a/ick2/workapi_tests.py +++ b/ick2/workapi_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2019 Lars Wirzenius +# Copyright (C) 2017-2018 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 @@ -15,6 +15,8 @@ import copy import os +import shutil +import tempfile import unittest @@ -24,9 +26,15 @@ import ick2 class WorkAPITests(unittest.TestCase): def setUp(self): - self.state = ick2.MemoryStore() + self.tempdir = tempfile.mkdtemp() + self.statedir = os.path.join(self.tempdir, 'state/dir') + self.state = ick2.FilePersistentState() + self.state.set_directory(self.statedir) self.claims = None + def tearDown(self): + shutil.rmtree(self.tempdir) + def create_project_api(self): pipeline = { 'pipeline': 'build', @@ -36,9 +44,7 @@ class WorkAPITests(unittest.TestCase): ], } - getter = DummyTokenGetter() pipeapi = ick2.PipelineAPI(self.state) - pipeapi.set_token_getter(getter) pipeapi.create(pipeline) project = { @@ -49,7 +55,6 @@ class WorkAPITests(unittest.TestCase): 'pipelines': ['build'], } api = ick2.ProjectAPI(self.state) - api.set_token_getter(getter) api.create(project) return api @@ -60,17 +65,12 @@ class WorkAPITests(unittest.TestCase): self.claims = { 'aud': 'asterix', } - getter = DummyTokenGetter() api = ick2.WorkerAPI(self.state) - api.set_token_getter(getter) api.create(worker, claims=self.claims) return api def create_work_api(self): - getter = DummyTokenGetter() - api = ick2.WorkAPI(self.state) - api.set_token_getter(getter) - return api + return ick2.WorkAPI(self.state) def test_worker_gets_no_work_when_no_builds_have_been_triggered(self): self.create_project_api() @@ -295,9 +295,3 @@ class WorkAPITests(unittest.TestCase): # Ask for work again. self.assertEqual(work.get_work(claims=self.claims), {}) - - -class DummyTokenGetter: - - def get_token(self): - return 'DUMMY.TOKEN' |