summaryrefslogtreecommitdiff
path: root/ick2/projectapi_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@exolobe1>2018-05-13 15:30:23 +0300
committerLars Wirzenius <liw@liw.fi>2018-05-17 21:44:59 +0300
commitb11d31ef23c5dfee6bfa54afbec47fc8b8bab7b1 (patch)
tree2e6b085f8fb023d53c8ac20a97aef2c7d1c11d4b /ick2/projectapi_tests.py
parent531dd2c50bfdfcf50bb37f57cf9fc2b69787adcf (diff)
downloadick2-b11d31ef23c5dfee6bfa54afbec47fc8b8bab7b1.tar.gz
Change: how controller stores persistent data
Replace old State class with new FilePersistentState and TransactionalState classes. Use new Resource class instead of raw dicts. Use context managers for creating, updating resources, to avoid mistakes from accidentally not saving changes. Overall persistence should now be rather simpler. This should open up a possibility for changing the controller to insert more actions into the build graph, to trigger notifcations via the workers.
Diffstat (limited to 'ick2/projectapi_tests.py')
-rw-r--r--ick2/projectapi_tests.py47
1 files changed, 2 insertions, 45 deletions
diff --git a/ick2/projectapi_tests.py b/ick2/projectapi_tests.py
index 2ef1dbe..b6ec9e9 100644
--- a/ick2/projectapi_tests.py
+++ b/ick2/projectapi_tests.py
@@ -19,9 +19,6 @@ import tempfile
import unittest
-import yaml
-
-
import ick2
@@ -30,8 +27,8 @@ class ProjectAPITests(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)
+ self.state = ick2.FilePersistentState()
+ self.state.set_directory(self.statedir)
def tearDown(self):
shutil.rmtree(self.tempdir)
@@ -59,15 +56,6 @@ class ProjectAPITests(unittest.TestCase):
project['next_build_id'] = None
self.assertEqual(new, project)
self.assertEqual(api.list(), {'projects': [new]})
- dirname = os.path.join(self.statedir, 'projects')
- filename = os.listdir(dirname)[0]
- obj = yaml.safe_load(open(os.path.join(dirname, filename)))
- self.assertEqual(api.get_status('foo'), {'status': 'idle'})
-
- def test_raises_error_when_getting_missing_project_status(self):
- api = self.create_api()
- with self.assertRaises(ick2.NotFound):
- api.get_status('does-not-exist')
def test_loads_projects_from_state_directory(self):
project = {
@@ -121,34 +109,3 @@ class ProjectAPITests(unittest.TestCase):
api = self.create_api()
with self.assertRaises(ick2.NotFound):
api.delete('foo')
-
- def test_updates_project_status(self):
- project = {
- 'project': 'foo',
- }
- api = self.create_api()
- api.create(project)
- self.assertEqual(api.get_status('foo'), {'status': 'idle'})
-
- with self.assertRaises(ick2.WrongProjectStatus):
- api.set_status('foo', 'build')
-
- api.set_status('foo', 'triggered')
- self.assertEqual(api.get_status('foo'), {'status': 'triggered'})
-
- with self.assertRaises(ick2.WrongProjectStatus):
- api.set_status('foo', 'idle')
-
- api.set_status('foo', 'building')
- self.assertEqual(api.get_status('foo'), {'status': 'building'})
-
- with self.assertRaises(ick2.WrongProjectStatus):
- api.set_status('foo', 'triggered')
-
- api.set_status('foo', 'idle')
- self.assertEqual(api.get_status('foo'), {'status': 'idle'})
-
- def test_raises_error_updating_status_of_missing_pipeline(self):
- api = self.create_api()
- with self.assertRaises(ick2.NotFound):
- api.set_status('does-not-exist', 'triggered')