Exemple #1
0
 def test_default_capabilities(self):
     environment = DockerEnvironment.from_options(
         PortableOptions(sdk_location='container'))
     context = pipeline_context.PipelineContext()
     proto = environment.to_runner_api(context)
     self.assertEqual(set(proto.capabilities),
                      set(environments.python_sdk_capabilities()))
Exemple #2
0
 def test_process_variables_empty(self):
     options = PortableOptions([
         '--environment_type=PROCESS',
         '--environment_option=process_command=foo',
         '--sdk_location=container'
     ])
     environment = ProcessEnvironment.from_options(options)
     self.assertEqual(environment.command, 'foo')
     self.assertEqual(environment.env, {})
Exemple #3
0
 def test_process_variables_missing_rvalue(self):
     with self.assertRaises(ValueError):
         options = PortableOptions([
             '--environment_type=PROCESS',
             '--environment_option=process_command=foo',
             '--environment_option=process_variables='
             'BASH_VARIABLE_ONE=spam,MISSING_RVALUE',
             '--sdk_location=container'
         ])
         ProcessEnvironment.from_options(options)
 def test_environments_with_same_hints_are_equal(self):
     options = PortableOptions([
         '--environment_type=PROCESS',
         '--environment_option=process_command=foo',
         '--sdk_location=container',
         '--resource_hint=accelerator=gpu',
     ])
     environment1 = ProcessEnvironment.from_options(options)
     environment2 = ProcessEnvironment.from_options(options)
     self.assertEqual(environment1, environment2)
Exemple #5
0
 def test_process_variables_set(self):
     options = PortableOptions([
         '--environment_type=PROCESS',
         '--environment_option=process_command=foo',
         '--environment_option=process_variables='
         'BASH_VARIABLE_ONE=spam,BASH_VARIABLE_TWO=ham',
         '--sdk_location=container'
     ])
     environment = ProcessEnvironment.from_options(options)
     self.assertEqual(environment.command, 'foo')
     self.assertEqual(environment.env, {
         'BASH_VARIABLE_ONE': 'spam',
         'BASH_VARIABLE_TWO': 'ham'
     })