summaryrefslogtreecommitdiff
path: root/ick2/projectapi_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-11-26 16:41:33 +0100
committerLars Wirzenius <liw@liw.fi>2017-11-26 17:59:59 +0100
commit964e646b2c26bcb007390dc6af625835f98887ec (patch)
treeae7ea88c5894ad71167959ed82d81b984f78b5e7 /ick2/projectapi_tests.py
parentf0ccb8150a67b10e11b3358d6385e31619e6d1e3 (diff)
downloadick2-964e646b2c26bcb007390dc6af625835f98887ec.tar.gz
Update: project and work apis to handle named pipelines
Diffstat (limited to 'ick2/projectapi_tests.py')
-rw-r--r--ick2/projectapi_tests.py56
1 files changed, 32 insertions, 24 deletions
diff --git a/ick2/projectapi_tests.py b/ick2/projectapi_tests.py
index ae5190e..4e55ccf 100644
--- a/ick2/projectapi_tests.py
+++ b/ick2/projectapi_tests.py
@@ -36,28 +36,32 @@ class ProjectAPITests(unittest.TestCase):
def create_api(self):
return ick2.ProjectAPI(self.state)
+ def create_pipeline_api(self):
+ return ick2.PipelineAPI(self.state)
+
def test_has_not_projects_initially(self):
api = self.create_api()
self.assertEqual(api.list(), {'projects': []})
def test_creates_project(self):
+ pipeline = {
+ 'name': 'build',
+ 'actions': [
+ {'shell': 'step-1'},
+ ],
+ }
+ pipeapi = self.create_pipeline_api()
+ pipeapi.create(pipeline)
+
project = {
'project': 'foo',
- 'pipelines': [
- {
- 'name': 'build',
- 'actions': [
- {
- 'shell': 'step-1',
- },
- ],
- },
- ],
+ 'pipelines': ['build'],
'parameters': {
'foo': 'bar',
}
}
api = self.create_api()
+
self.assertEqual(api.create(project), project)
self.assertEqual(api.list(), {'projects': [project]})
self.assertEqual(api.get_pipeline('foo', 'build'), {'status': 'idle'})
@@ -85,7 +89,7 @@ class ProjectAPITests(unittest.TestCase):
def test_loads_projects_from_state_directory(self):
project = {
'project': 'foo',
- 'shell_steps': ['build'],
+ 'pipelines': ['build'],
}
api = self.create_api()
api.create(project)
@@ -96,7 +100,7 @@ class ProjectAPITests(unittest.TestCase):
def test_gets_named_project(self):
project = {
'project': 'foo',
- 'shell_steps': ['build'],
+ 'pipelines': ['build'],
}
api = self.create_api()
api.create(project)
@@ -105,7 +109,7 @@ class ProjectAPITests(unittest.TestCase):
def test_updates_named_project(self):
project_v1 = {
'project': 'foo',
- 'shell_steps': ['build'],
+ 'pipelines': ['build'],
}
project_v2 = dict(project_v1)
project_v2['shell_steps'] = ['build it using magic']
@@ -118,7 +122,7 @@ class ProjectAPITests(unittest.TestCase):
def test_deletes_named_project(self):
project = {
'project': 'foo',
- 'shell_steps': ['build'],
+ 'pipelines': ['build'],
}
api = self.create_api()
api.create(project)
@@ -133,27 +137,29 @@ class ProjectAPITests(unittest.TestCase):
api.delete('foo')
def test_updates_pipeline_status(self):
+ pipeline = {
+ 'name': 'build',
+ 'actions': [
+ {'shell': 'step-1'},
+ ],
+ }
+ pipeapi = self.create_pipeline_api()
+ pipeapi.create(pipeline)
+
project = {
'project': 'foo',
- 'pipelines': [
- {
- 'name': 'build',
- 'actions': [
- {
- 'shell': 'step-1',
- },
- ],
- },
- ],
+ 'pipelines': ['build'],
}
api = self.create_api()
api.create(project)
self.assertEqual(api.get_pipeline('foo', 'build'), {'status': 'idle'})
+ self.assertEqual(pipeapi.show('build'), pipeline)
with self.assertRaises(ick2.WrongPipelineStatus):
api.set_pipeline('building', 'foo', 'build')
api.set_pipeline('triggered', 'foo', 'build')
+ self.assertEqual(pipeapi.show('build'), pipeline)
self.assertEqual(
api.get_pipeline('foo', 'build'),
{'status': 'triggered'}
@@ -163,6 +169,7 @@ class ProjectAPITests(unittest.TestCase):
api.set_pipeline('idle', 'foo', 'build')
api.set_pipeline('building', 'foo', 'build')
+ self.assertEqual(pipeapi.show('build'), pipeline)
self.assertEqual(
api.get_pipeline('foo', 'build'),
{'status': 'building'}
@@ -172,6 +179,7 @@ class ProjectAPITests(unittest.TestCase):
api.set_pipeline('triggered', 'foo', 'build')
api.set_pipeline('idle', 'foo', 'build')
+ self.assertEqual(pipeapi.show('build'), pipeline)
self.assertEqual(
api.get_pipeline('foo', 'build'),
{'status': 'idle'}