Exemplo n.º 1
0
    def test_noop_if_output_key_does_not_exist(self):
        original = {'foo': 'bar'}
        parsed = original.copy()

        handlers.decode_console_output(parsed)
        # Should be unchanged because the 'Output'
        # key is not in the output.
        self.assertEqual(parsed, original)
Exemplo n.º 2
0
    def test_noop_if_output_key_does_not_exist(self):
        original = {'foo': 'bar'}
        parsed = original.copy()

        handlers.decode_console_output(parsed)
        # Should be unchanged because the 'Output'
        # key is not in the output.
        self.assertEqual(parsed, original)
Exemplo n.º 3
0
def _decode_console_output_as_bytes(parsed, **kwargs):
    """Provide console output as bytes in OutputBytes.

       For this to be useful, the session has to have had the
       decode_console_output handler unregistered already.

       https://github.com/boto/botocore/issues/1351 ."""
    if 'Output' not in parsed:
        return
    orig = parsed['Output']
    handlers.decode_console_output(parsed, **kwargs)
    parsed['OutputBytes'] = base64.b64decode(orig)
Exemplo n.º 4
0
 def test_get_console_output_cant_be_decoded(self):
     parsed = {'Output': 1}
     handlers.decode_console_output(parsed)
     self.assertEqual(parsed['Output'], 1)
Exemplo n.º 5
0
 def test_get_console_output(self):
     parsed = {'Output': base64.b64encode(b'foobar').decode('utf-8')}
     handlers.decode_console_output(parsed)
     self.assertEqual(parsed['Output'], 'foobar')
Exemplo n.º 6
0
 def test_get_console_output_cant_be_decoded(self):
     parsed = {'Output': 1}
     handlers.decode_console_output(parsed)
     self.assertEqual(parsed['Output'], 1)
Exemplo n.º 7
0
 def test_get_console_output(self):
     parsed = {'Output': base64.b64encode(b'foobar').decode('utf-8')}
     handlers.decode_console_output(parsed)
     self.assertEqual(parsed['Output'], 'foobar')
Exemplo n.º 8
0
 def test_get_console_output_bad_unicode_errors(self):
     original = base64.b64encode(b'before\xffafter').decode('utf-8')
     parsed = {'Output': original}
     handlers.decode_console_output(parsed)
     self.assertEqual(parsed['Output'], u'before\ufffdafter')
Exemplo n.º 9
0
 def test_get_console_output_bad_unicode_errors(self):
     original = base64.b64encode(b'before\xffafter').decode('utf-8')
     parsed = {'Output': original}
     handlers.decode_console_output(parsed)
     self.assertEqual(parsed['Output'], u'before\ufffdafter')
Exemplo n.º 10
0
 def test_get_console_output(self):
     parsed = {"Output": base64.b64encode(b"foobar").decode("utf-8")}
     handlers.decode_console_output(parsed)
     self.assertEqual(parsed["Output"], "foobar")