Esempio n. 1
0
    def test_with_config_and_variables_not_in_environ(self):
        env = {"bar": "old-bar-value"}
        # Setup a configuration object with values for baz.
        # Note that baz is *not* declared in the job's environ line.
        from plainbox.impl.applogic import PlainBoxConfig

        config = PlainBoxConfig()
        config.environment = {"baz": "baz-value"}
        # Ask the job to modify the environment
        self.job.modify_execution_environment(env, self.session_dir, self.checkbox_data_dir, config)
        # bar from the old environment
        self.assertEqual(env["bar"], "old-bar-value")
        # baz from the config environment
        self.assertEqual(env["baz"], "baz-value")
Esempio n. 2
0
 def test_with_config_and_variables_not_in_environ(self):
     env = {'bar': 'old-bar-value'}
     # Setup a configuration object with values for baz.
     # Note that baz is *not* declared in the job's environ line.
     from plainbox.impl.applogic import PlainBoxConfig
     config = PlainBoxConfig()
     config.environment = {'baz': 'baz-value'}
     # Ask the job to modify the environment
     self.job.modify_execution_environment(env, self.session_dir,
                                           self.checkbox_data_dir, config)
     # bar from the old environment
     self.assertEqual(env['bar'], 'old-bar-value')
     # baz from the config environment
     self.assertEqual(env['baz'], 'baz-value')
Esempio n. 3
0
    def proxy_test(self, environment, proxies):
        test_environment = environment
        test_proxies = proxies
        test_config = PlainBoxConfig()
        test_config.environment = test_environment

        transport = SubmissionServiceTransport(
            self.valid_url, self.valid_option_string)
        dummy_data = BytesIO(b"some data to send")

        requests.post.return_value = MagicMock(name='response')
        requests.post.return_value.status_code = 200
        requests.post.return_value.text = '{"id": 768}'
        result = transport.send(dummy_data, config=test_config)
        self.assertTrue(result)
        requests.post.assert_called_with(
            self.valid_url, data=dummy_data,
            proxies=test_proxies)
Esempio n. 4
0
    def proxy_test(self, environment, proxies):
        test_environment = environment
        test_proxies = proxies
        test_config = PlainBoxConfig()
        test_config.environment = test_environment

        transport = CertificationTransport(
            self.valid_url, self.valid_option_string)
        dummy_data = BytesIO(b"some data to send")

        requests.post.return_value = MagicMock(name='response')
        requests.post.return_value.status_code = 200
        requests.post.return_value.text = '{"id": 768}'
        result = transport.send(dummy_data, config=test_config)
        self.assertTrue(result)
        requests.post.assert_called_with(
            self.valid_url, files={'data': dummy_data},
            headers={'X_HARDWARE_ID': self.valid_secure_id},
            proxies=test_proxies)
Esempio n. 5
0
    def test_with_config_and_environ_variables(self):
        env = {
            "PATH": "",
            # foo is not defined in the environment
            "bar": "old-bar-value"
            # froz is not defined in the environment
        }
        # Setup a configuration object with values for foo and bar
        from plainbox.impl.applogic import PlainBoxConfig

        config = PlainBoxConfig()
        config.environment = {"foo": "foo-value", "bar": "bar-value"}
        # Ask the job to modify the environment
        self.job.modify_execution_environment(env, self.session_dir, self.checkbox_data_dir, config)
        # foo got copied from the config
        self.assertEqual(env["foo"], "foo-value")
        # bar from the old environment
        self.assertEqual(env["bar"], "old-bar-value")
        # froz is still empty
        self.assertNotIn("froz", env)
Esempio n. 6
0
 def test_with_config_and_environ_variables(self):
     env = {
         "PATH": "",
         # foo is not defined in the environment
         'bar': 'old-bar-value'
         # froz is not defined in the environment
     }
     # Setup a configuration object with values for foo and bar
     from plainbox.impl.applogic import PlainBoxConfig
     config = PlainBoxConfig()
     config.environment = {'foo': 'foo-value', 'bar': 'bar-value'}
     # Ask the job to modify the environment
     self.job.modify_execution_environment(env, self.session_dir,
                                           self.checkbox_data_dir, config)
     # foo got copied from the config
     self.assertEqual(env['foo'], 'foo-value')
     # bar from the old environment
     self.assertEqual(env['bar'], 'old-bar-value')
     # froz is still empty
     self.assertNotIn('froz', env)
Esempio n. 7
0
 def test_with_config_and_environ_variables(self):
     env = {
         "PATH": "",
         # foo is not defined in the environment
         'bar': 'old-bar-value'
         # froz is not defined in the environment
     }
     # Setup a configuration object with values for foo and bar
     from plainbox.impl.applogic import PlainBoxConfig
     config = PlainBoxConfig()
     config.environment = {
         'foo': 'foo-value',
         'bar': 'bar-value'
     }
     # Ask the job to modify the environment
     self.job.modify_execution_environment(env, self.session_dir, config)
     # foo got copied from the config
     self.assertEqual(env['foo'], 'foo-value')
     # bar from the old environment
     self.assertEqual(env['bar'], 'old-bar-value')
     # froz is still empty
     self.assertNotIn('froz', env)
Esempio n. 8
0
    def proxy_test(self, environment, proxies):
        test_environment = environment
        test_proxies = proxies
        test_config = PlainBoxConfig()
        test_config.environment = test_environment

        transport = CertificationTransport(self.valid_url,
                                           self.valid_option_string,
                                           config=test_config)
        dummy_data = BytesIO(b"some data to send")

        requests.post.return_value = MagicMock(name='response')
        requests.post.return_value.status_code = 200
        requests.post.return_value.text = '{"id": 768}'
        result = transport.send(dummy_data)

        self.assertTrue(result)

        requests.post.assert_called_with(self.valid_url,
                                         files={'data': dummy_data},
                                         headers={'X_HARDWARE_ID':
                                         self.valid_secure_id},
                                         proxies=test_proxies)