<s> import logging <EOL> import ssl <EOL> try : <EOL> import unittest2 as unittest <EOL> except ImportError : <EOL> import unittest <EOL> from amqpstorm import UriConnection <EOL> logging . basicConfig ( level = logging . DEBUG ) <EOL> class UriConnectionTests ( unittest . TestCase ) : <EOL> def test_uri_default ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , '<STR_LIT:localhost>' ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT:password>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , '<STR_LIT:/>' ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT:port>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , <NUM_LIT:30> ) <EOL> self . assertFalse ( connection . parameters [ '<STR_LIT>' ] ) <EOL> def test_uri_set_hostname ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' <EOL> '<STR_LIT>' , True ) <EOL> self . assertIsInstance ( connection . parameters [ '<STR_LIT>' ] , str ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_uri_set_username ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' <EOL> '<STR_LIT>' , True ) <EOL> self . assertIsInstance ( connection . parameters [ '<STR_LIT:username>' ] , str ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT:username>' ] , '<STR_LIT:username>' ) <EOL> def test_uri_set_password ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' <EOL> '<STR_LIT>' , True ) <EOL> self . assertIsInstance ( connection . parameters [ '<STR_LIT:password>' ] , str ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT:password>' ] , '<STR_LIT:password>' ) <EOL> def test_uri_set_port ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> self . assertIsInstance ( connection . parameters [ '<STR_LIT:port>' ] , int ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT:port>' ] , <NUM_LIT> ) <EOL> def test_uri_set_heartbeat ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' <EOL> '<STR_LIT>' , True ) <EOL> self . assertIsInstance ( connection . parameters [ '<STR_LIT>' ] , int ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_uri_set_timeout ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' <EOL> '<STR_LIT>' , True ) <EOL> self . assertIsInstance ( connection . parameters [ '<STR_LIT>' ] , int ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_uri_set_virtual_host ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> self . assertIsInstance ( connection . parameters [ '<STR_LIT>' ] , str ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_uri_set_ssl ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , True ) <EOL> self . assertTrue ( connection . parameters [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> ssl . PROTOCOL_TLSv1 ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> ssl . CERT_REQUIRED ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( connection . parameters [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> '<STR_LIT:test>' ) <EOL> def test_uri_get_ssl_version ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> self . assertEqual ( ssl . PROTOCOL_TLSv1 , <EOL> connection . _get_ssl_version ( '<STR_LIT>' ) ) <EOL> def test_uri_get_invalid_ssl_version ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> self . assertEqual ( connection . _get_ssl_version ( '<STR_LIT>' ) , <EOL> ssl . PROTOCOL_TLSv1 ) <EOL> def test_uri_get_ssl_validation ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> self . assertEqual ( ssl . CERT_REQUIRED , <EOL> connection . _get_ssl_validation ( '<STR_LIT>' ) ) <EOL> def test_uri_get_invalid_ssl_validation ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> self . assertEqual ( ssl . CERT_NONE , <EOL> connection . _get_ssl_validation ( '<STR_LIT>' ) ) <EOL> def test_uri_get_ssl_options ( self ) : <EOL> connection = UriConnection ( '<STR_LIT>' , True ) <EOL> ssl_kwargs = { <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] <EOL> } <EOL> ssl_options = connection . _parse_ssl_options ( ssl_kwargs ) <EOL> self . assertEqual ( ssl_options [ '<STR_LIT>' ] , ssl . CERT_REQUIRED ) <EOL> self . assertEqual ( ssl_options [ '<STR_LIT>' ] , ssl . PROTOCOL_TLSv1 ) <EOL> self . assertEqual ( ssl_options [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( ssl_options [ '<STR_LIT>' ] , '<STR_LIT>' ) </s>
