<s> from . . import * <EOL> from mock import patch <EOL> from nose . tools import assert_equal , assert_not_equal <EOL> from nose . tools import nottest <EOL> from flanker . addresslib import address , validate <EOL> @ nottest <EOL> def mock_exchanger_lookup ( arg , metrics = False ) : <EOL> mtimes = { '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT>' : <NUM_LIT:20> , '<STR_LIT>' : <NUM_LIT:30> } <EOL> if metrics is True : <EOL> if arg == '<STR_LIT>' or arg == '<STR_LIT>' or arg == '<STR_LIT>' : <EOL> return ( '<STR_LIT>' , mtimes ) <EOL> else : <EOL> return ( None , mtimes ) <EOL> else : <EOL> if arg == '<STR_LIT>' or arg == '<STR_LIT>' or arg == '<STR_LIT>' : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return None <EOL> def test_metrics_parse ( ) : <EOL> assert_equal ( len ( address . parse ( '<STR_LIT>' , metrics = True ) ) , <NUM_LIT:2> ) <EOL> p , m = address . parse ( '<STR_LIT>' , metrics = True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( isinstance ( address . parse ( '<STR_LIT>' , metrics = False ) , address . EmailAddress ) , True ) <EOL> assert_equal ( isinstance ( address . parse ( '<STR_LIT>' ) , address . EmailAddress ) , True ) <EOL> def test_metrics_parse_list ( ) : <EOL> assert_equal ( len ( address . parse_list ( '<STR_LIT>' , metrics = True ) ) , <NUM_LIT:2> ) <EOL> p , m = address . parse_list ( '<STR_LIT>' , metrics = True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( isinstance ( address . parse_list ( '<STR_LIT>' , metrics = False ) , address . AddressList ) , True ) <EOL> assert_equal ( isinstance ( address . parse_list ( '<STR_LIT>' ) , address . AddressList ) , True ) <EOL> def test_metrics_validate_address ( ) : <EOL> with patch . object ( validate , '<STR_LIT>' ) as mock_method : <EOL> mock_method . side_effect = mock_exchanger_lookup <EOL> assert_equal ( len ( address . validate_address ( '<STR_LIT>' , metrics = True ) ) , <NUM_LIT:2> ) <EOL> p , m = address . validate_address ( '<STR_LIT>' , metrics = True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( isinstance ( address . validate_address ( '<STR_LIT>' , metrics = False ) , address . EmailAddress ) , True ) <EOL> assert_equal ( isinstance ( address . validate_address ( '<STR_LIT>' ) , address . EmailAddress ) , True ) <EOL> def test_metrics_validate_list ( ) : <EOL> with patch . object ( validate , '<STR_LIT>' ) as mock_method : <EOL> mock_method . side_effect = mock_exchanger_lookup <EOL> assert_equal ( len ( address . validate_list ( '<STR_LIT>' , metrics = True ) ) , <NUM_LIT:2> ) <EOL> p , m = address . validate_list ( '<STR_LIT>' , metrics = True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( '<STR_LIT>' in m , True ) <EOL> assert_equal ( isinstance ( address . validate_list ( '<STR_LIT>' , metrics = False ) , address . AddressList ) , True ) <EOL> assert_equal ( isinstance ( address . validate_list ( '<STR_LIT>' ) , address . AddressList ) , True ) </s>
