コード例 #1
0
 def test_mkGoodCommandScript(self):
     p1 = Category.mkParameter(name='venue',
                               description='Where am I today?',
                               datatype='STRING')
     tvalues = {
         'name': 'Hello <venue>',
         'description': 'Stereotypical rock star intro',
         'platforms': ['LINUX'],
         'type': 'COMMAND',
         'payload': 'echo "hello $1"',
         'parameters': [p1]
     }
     actual = Category.mkScript(name=tvalues['name'],
                                description=tvalues['description'],
                                platforms=tvalues['platforms'],
                                execution_type=tvalues['type'],
                                payload=tvalues['payload'],
                                parameters=tvalues['parameters'])
     expected = {
         'name': tvalues['name'],
         'description': tvalues['description'],
         'platforms': tvalues['platforms'],
         'executionType': tvalues['type'],
         'command': tvalues['payload'],
         'parameters': tvalues['parameters']
     }
     assert actual == expected
コード例 #2
0
 def test_mkBadParameter(self):
     with self.assertRaises(AssertionError):
         Category.mkParameter(name='pname',
                              description='pdesc',
                              datatype='STRING',
                              optional=True
                              # deliberately missing default value
                              )
コード例 #3
0
 def test_mkGoodPythonScript(self):
     tvalues = {
         'name': 'Hello <venue>',
         'description': 'Python rock star intro',
         'platforms': ['LINUX'],
         'type': 'PYTHON',
         'process_name': 'jabberwocky',
         'service_name': 'silmarilion',
         'install_timeout': 'a really long time'
     }
     actual = Category.mkScript(name=tvalues['name'],
                                description=tvalues['description'],
                                platforms=tvalues['platforms'],
                                execution_type=tvalues['type'],
                                script_name=self.testfile,
                                payload_file=self.testfile,
                                install_timeout=tvalues['install_timeout'],
                                process_name=tvalues['process_name'],
                                service_name=tvalues['service_name'])
     expected = {
         'name': tvalues['name'],
         'description': tvalues['description'],
         'platforms': tvalues['platforms'],
         'executionType': tvalues['type'],
         'attachment': {
             'name': self.testfile,
             'file': self.content_64
         },
         'installTimeout': tvalues['install_timeout'],
         'processName': tvalues['process_name'],
         'serviceName': tvalues['service_name']
     }
     assert actual == expected
コード例 #4
0
 def test_mkBadScript(self):
     tvalues = {
         'name': 'sname',
         'description': 'pdesc',
         'platforms': ['LINUX']
     }
     with self.assertRaises(AssertionError):
         Category.mkScript(execution_type='Firing squad is not valid',
                           name=tvalues['name'],
                           description=tvalues['description'],
                           platforms=tvalues['platforms'],
                           payload_file=self.testfile)
     with self.assertRaises(AssertionError):
         Category.mkScript(execution_type='COMMAND',
                           name=tvalues['name'],
                           description=tvalues['description'],
                           platforms=tvalues['platforms'],
                           payload='if there is a payload',
                           payload_file='cannot have payload_file as well')
コード例 #5
0
 def test_mkGoodParameter(self):
     tvalues = {
         'name': 'venue',
         'description': 'Where am I today?',
         'type': 'STRING'
     }
     actual = Category.mkParameter(name=tvalues['name'],
                                   description=tvalues['description'],
                                   datatype=tvalues['type'])
     expected = {
         'name': tvalues['name'],
         'description': tvalues['description'],
         'dataType': tvalues['type'],
         'type': 'REQUIRED',
         'defaultValue': None
     }
     assert actual == expected
コード例 #6
0
 def test_mkAttachment(self):
     tvalues = {'name': self.testfile, 'content': self.content_raw}
     actual = Category.mkAttachment(name=tvalues['name'],
                                    payload=tvalues['content'])
     expected = {'name': tvalues['name'], 'file': tvalues['content']}
     assert actual == expected