<s> import json <EOL> import unittest <EOL> import mock <EOL> import requests <EOL> import datetime <EOL> import urbanairship as ua <EOL> class TestDeviceInfo ( unittest . TestCase ) : <EOL> def test_channel_list ( self ) : <EOL> with mock . patch . object ( ua . Airship , '<STR_LIT>' ) as mock_request : <EOL> response = requests . Response ( ) <EOL> response . _content = json . dumps ( <EOL> { <EOL> '<STR_LIT>' : [ <EOL> { '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' } <EOL> ] <EOL> } <EOL> ) . encode ( '<STR_LIT:utf-8>' ) <EOL> response . status_code = <NUM_LIT:200> <EOL> mock_request . return_value = response <EOL> url = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> airship = ua . Airship ( '<STR_LIT:key>' , '<STR_LIT>' ) <EOL> channel_list = ua . ChannelList ( airship , url ) <EOL> channel_id_list = [ ] <EOL> for channel in channel_list : <EOL> channel_id_list . append ( channel . channel_id ) <EOL> self . assertEqual ( <EOL> channel_id_list [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> channel_id_list [ <NUM_LIT:1> ] , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> channel_id_list [ <NUM_LIT:2> ] , <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_channel_lookup ( self ) : <EOL> with mock . patch . object ( ua . Airship , '<STR_LIT>' ) as mock_request : <EOL> response = requests . Response ( ) <EOL> response . _content = json . dumps ( <EOL> { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:false>' , <EOL> '<STR_LIT>' : '<STR_LIT:false>' , <EOL> '<STR_LIT>' : '<STR_LIT:false>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:null>' , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:start>' : '<STR_LIT:null>' , <EOL> '<STR_LIT:end>' : '<STR_LIT:null>' <EOL> } , <EOL> '<STR_LIT>' : '<STR_LIT:null>' , <EOL> } <EOL> } <EOL> } <EOL> ) . encode ( '<STR_LIT:utf-8>' ) <EOL> response . status_code = <NUM_LIT:200> <EOL> mock_request . return_value = response <EOL> airship = ua . Airship ( '<STR_LIT:key>' , '<STR_LIT>' ) <EOL> channel_id = '<STR_LIT>' <EOL> channel_lookup = ua . ChannelInfo . lookup ( airship , channel_id ) <EOL> date_created = ( <EOL> datetime . datetime . strptime ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> last_registration_date = ( <EOL> datetime . datetime . strptime ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> ) <EOL> self . assertEqual ( channel_lookup . channel_id , channel_id ) <EOL> self . assertEqual ( channel_lookup . device_type , '<STR_LIT>' ) <EOL> self . assertEqual ( channel_lookup . installed , '<STR_LIT:false>' ) <EOL> self . assertEqual ( channel_lookup . opt_in , '<STR_LIT:false>' ) <EOL> self . assertEqual ( channel_lookup . background , '<STR_LIT:false>' ) <EOL> self . assertEqual ( channel_lookup . alias , '<STR_LIT:null>' ) <EOL> self . assertEqual ( channel_lookup . tags , [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( channel_lookup . created , date_created ) <EOL> self . assertEqual ( <EOL> channel_lookup . push_address , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( <EOL> channel_lookup . last_registration , <EOL> last_registration_date <EOL> ) <EOL> self . assertEqual ( <EOL> channel_lookup . ios , <EOL> { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : { '<STR_LIT:start>' : '<STR_LIT:null>' , '<STR_LIT:end>' : '<STR_LIT:null>' } , <EOL> '<STR_LIT>' : '<STR_LIT:null>' <EOL> } <EOL> ) <EOL> def test_device_token_feedback ( self ) : <EOL> with mock . patch . object ( ua . Airship , '<STR_LIT>' ) as mock_request : <EOL> response = requests . Response ( ) <EOL> response . _content = json . dumps ( [ <EOL> { <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ] ) . encode ( '<STR_LIT:utf-8>' ) <EOL> response . status_code = <NUM_LIT:200> <EOL> mock_request . return_value = response <EOL> airship = ua . Airship ( '<STR_LIT:key>' , '<STR_LIT>' ) <EOL> feedback = ua . Feedback . device_token ( <EOL> airship , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT> ) <EOL> ) <EOL> date = datetime . datetime . strptime ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> feedback , <EOL> [ <EOL> { <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : ( '<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> '<STR_LIT>' : date <EOL> } <EOL> ] <EOL> ) <EOL> mock_request . assert_called_with ( <EOL> method = '<STR_LIT:GET>' , <EOL> body = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> version = <NUM_LIT:3> , <EOL> params = { '<STR_LIT>' : '<STR_LIT>' } <EOL> ) <EOL> def test_apid_feedback ( self ) : <EOL> with mock . patch . object ( ua . Airship , '<STR_LIT>' ) as mock_request : <EOL> response = requests . Response ( ) <EOL> response . _content = json . dumps ( [ <EOL> { <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:null>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ] ) . encode ( '<STR_LIT:utf-8>' ) <EOL> response . status_code = <NUM_LIT:200> <EOL> mock_request . return_value = response <EOL> airship = ua . Airship ( '<STR_LIT:key>' , '<STR_LIT>' ) <EOL> feedback = ua . Feedback . apid ( <EOL> airship , <EOL> datetime . datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> ) <EOL> date = datetime . datetime . strptime ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> feedback , <EOL> [ <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : date , <EOL> '<STR_LIT>' : '<STR_LIT:null>' <EOL> } <EOL> ] <EOL> ) <EOL> mock_request . assert_called_with ( <EOL> method = '<STR_LIT:GET>' , <EOL> body = '<STR_LIT>' , <EOL> url = '<STR_LIT>' , <EOL> version = <NUM_LIT:3> , <EOL> params = { '<STR_LIT>' : '<STR_LIT>' } <EOL> ) <EOL> def test_device_pin_info ( self ) : <EOL> with mock . patch . object ( ua . Airship , '<STR_LIT>' ) as mock_request : <EOL> response = requests . Response ( ) <EOL> response . _content = json . dumps ( <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:true>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ) . encode ( '<STR_LIT:utf-8>' ) <EOL> response . status_code = <NUM_LIT:200> <EOL> mock_request . return_value = response <EOL> airship = ua . Airship ( '<STR_LIT:key>' , '<STR_LIT>' ) <EOL> device_pin = '<STR_LIT>' <EOL> device_info = ua . DevicePINInfo . pin_lookup ( airship , device_pin ) <EOL> date_created = datetime . datetime . strptime ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> last_registration_date = datetime . datetime . strptime ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . assertEqual ( device_info [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( device_info [ '<STR_LIT>' ] , '<STR_LIT:true>' ) <EOL> self . assertEqual ( device_info [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( device_info [ '<STR_LIT>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertEqual ( device_info [ '<STR_LIT>' ] , date_created ) <EOL> self . assertEqual ( <EOL> device_info [ '<STR_LIT>' ] , last_registration_date <EOL> ) </s>
