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