Merge branch 'master' into 5417-not-start-pipeline-with-unreadable-inputs
[arvados.git] / sdk / python / tests / test_pipeline_template.py
1 # usage example:
2 #
3 # ARVADOS_API_TOKEN=abc ARVADOS_API_HOST=arvados.local python -m unittest discover
4
5 import unittest
6 import arvados
7 import apiclient
8 import run_test_server
9
10 class PipelineTemplateTest(run_test_server.TestCaseWithServers):
11     MAIN_SERVER = {}
12     KEEP_SERVER = {}
13
14     def runTest(self):
15         run_test_server.authorize_with("admin")
16         pt_uuid = arvados.api('v1').pipeline_templates().create(
17             body={'name':__file__}
18             ).execute()['uuid']
19         self.assertEqual(len(pt_uuid), 27,
20                          'Unexpected format of pipeline template UUID ("%s")'
21                          % pt_uuid)
22         components = {
23             'x': 'x',
24             '-x-': [1,2,{'foo':'bar'}],
25             'Boggis': {'Bunce': '[\'Bean\']'},
26             'SpassBox': True,
27             'spass_box': False,
28             'spass-box': [True, 'Maybe', False]
29             }
30         update_response = arvados.api('v1').pipeline_templates().update(
31             uuid=pt_uuid,
32             body={'components':components}
33             ).execute()
34         self.assertEqual('uuid' in update_response, True,
35                          'update() response did not include a uuid')
36         self.assertEqual(update_response['uuid'], pt_uuid,
37                          'update() response has a different uuid (%s, not %s)'
38                          % (update_response['uuid'], pt_uuid))
39         self.assertEqual(update_response['name'], __file__,
40                          'update() response has a different name (%s, not %s)'
41                          % (update_response['name'], __file__))
42         get_response = arvados.api('v1').pipeline_templates().get(
43             uuid=pt_uuid
44             ).execute()
45         self.assertEqual(get_response['components'], components,
46                          'components got munged by server (%s -> %s)'
47                          % (components, update_response['components']))
48         delete_response = arvados.api('v1').pipeline_templates().delete(
49             uuid=pt_uuid
50             ).execute()
51         self.assertEqual(delete_response['uuid'], pt_uuid,
52                          'delete() response has wrong uuid (%s, not %s)'
53                          % (delete_response['uuid'], pt_uuid))
54         with self.assertRaises(apiclient.errors.HttpError):
55             geterror_response = arvados.api('v1').pipeline_templates().get(
56                 uuid=pt_uuid
57                 ).execute()