<s> """<STR_LIT>""" <EOL> import datetime <EOL> import unittest <EOL> from googlemaps import convert <EOL> class ConvertTest ( unittest . TestCase ) : <EOL> def test_latlng ( self ) : <EOL> expected = "<STR_LIT>" <EOL> ll = { "<STR_LIT>" : <NUM_LIT:1> , "<STR_LIT>" : <NUM_LIT:2> } <EOL> self . assertEqual ( expected , convert . latlng ( ll ) ) <EOL> ll = [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> self . assertEqual ( expected , convert . latlng ( ll ) ) <EOL> ll = ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . assertEqual ( expected , convert . latlng ( ll ) ) <EOL> self . assertEqual ( expected , convert . latlng ( expected ) ) <EOL> with self . assertRaises ( TypeError ) : <EOL> convert . latlng ( <NUM_LIT:1> ) <EOL> def test_location_list ( self ) : <EOL> expected = "<STR_LIT>" <EOL> ll = [ { "<STR_LIT>" : <NUM_LIT:1> , "<STR_LIT>" : <NUM_LIT:2> } , { "<STR_LIT>" : <NUM_LIT:1> , "<STR_LIT>" : <NUM_LIT:2> } ] <EOL> self . assertEqual ( expected , convert . location_list ( ll ) ) <EOL> ll = [ [ <NUM_LIT:1> , <NUM_LIT:2> ] , [ <NUM_LIT:1> , <NUM_LIT:2> ] ] <EOL> self . assertEqual ( expected , convert . location_list ( ll ) ) <EOL> ll = [ ( <NUM_LIT:1> , <NUM_LIT:2> ) , [ <NUM_LIT:1> , <NUM_LIT:2> ] ] <EOL> self . assertEqual ( expected , convert . location_list ( ll ) ) <EOL> self . assertEqual ( expected , convert . location_list ( expected ) ) <EOL> with self . assertRaises ( TypeError ) : <EOL> convert . latlng ( <NUM_LIT:1> ) <EOL> def test_join_list ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , convert . join_list ( "<STR_LIT:|>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , convert . join_list ( "<STR_LIT:U+002C>" , [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:A>" ] ) ) <EOL> self . assertEqual ( "<STR_LIT>" , convert . join_list ( "<STR_LIT:U+002C>" , [ ] ) ) <EOL> self . assertEqual ( "<STR_LIT>" , convert . join_list ( "<STR_LIT:U+002C>" , ( "<STR_LIT:a>" , "<STR_LIT:B>" ) ) ) <EOL> def test_as_list ( self ) : <EOL> self . assertEqual ( [ <NUM_LIT:1> ] , convert . as_list ( <NUM_LIT:1> ) ) <EOL> self . assertEqual ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , convert . as_list ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) <EOL> self . assertEqual ( [ "<STR_LIT:string>" ] , convert . as_list ( "<STR_LIT:string>" ) ) <EOL> self . assertEqual ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , convert . as_list ( ( <NUM_LIT:1> , <NUM_LIT:2> ) ) ) <EOL> a_dict = { "<STR_LIT:a>" : <NUM_LIT:1> } <EOL> self . assertEqual ( [ a_dict ] , convert . as_list ( a_dict ) ) <EOL> def test_time ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , convert . time ( <NUM_LIT> ) ) <EOL> dt = datetime . datetime . fromtimestamp ( <NUM_LIT> ) <EOL> self . assertEqual ( "<STR_LIT>" , convert . time ( dt ) ) <EOL> def test_components ( self ) : <EOL> c = { "<STR_LIT>" : "<STR_LIT>" } <EOL> self . assertEqual ( "<STR_LIT>" , convert . components ( c ) ) <EOL> c = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT:foo>" : <NUM_LIT:1> } <EOL> self . assertEqual ( "<STR_LIT>" , convert . components ( c ) ) <EOL> with self . assertRaises ( TypeError ) : <EOL> convert . components ( "<STR_LIT:test>" ) <EOL> with self . assertRaises ( TypeError ) : <EOL> convert . components ( <NUM_LIT:1> ) <EOL> with self . assertRaises ( TypeError ) : <EOL> convert . components ( ( "<STR_LIT:c>" , "<STR_LIT:b>" ) ) <EOL> def test_bounds ( self ) : <EOL> ne = { "<STR_LIT>" : <NUM_LIT:1> , "<STR_LIT>" : <NUM_LIT:2> } <EOL> sw = ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> b = { "<STR_LIT>" : ne , "<STR_LIT>" : sw } <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> convert . bounds ( b ) ) <EOL> with self . assertRaises ( TypeError ) : <EOL> convert . bounds ( "<STR_LIT:test>" ) <EOL> def test_polyline_decode ( self ) : <EOL> syd_mel_route = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> points = convert . decode_polyline ( syd_mel_route ) <EOL> self . assertAlmostEqual ( - <NUM_LIT> , points [ <NUM_LIT:0> ] [ "<STR_LIT>" ] ) <EOL> self . assertAlmostEqual ( <NUM_LIT> , points [ <NUM_LIT:0> ] [ "<STR_LIT>" ] ) <EOL> self . assertAlmostEqual ( - <NUM_LIT> , points [ - <NUM_LIT:1> ] [ "<STR_LIT>" ] ) <EOL> self . assertAlmostEqual ( <NUM_LIT> , points [ - <NUM_LIT:1> ] [ "<STR_LIT>" ] ) <EOL> def test_polyline_round_trip ( self ) : <EOL> test_polyline = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> points = convert . decode_polyline ( test_polyline ) <EOL> actual_polyline = convert . encode_polyline ( points ) <EOL> self . assertEqual ( test_polyline , actual_polyline ) </s>
