<s> __author__ = '<STR_LIT>' <EOL> import getpass <EOL> import unittest <EOL> from gdata import test_data <EOL> import gdata . health <EOL> import gdata . health . service <EOL> username = '<STR_LIT>' <EOL> password = '<STR_LIT>' <EOL> class HealthQueryProfileListTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . health = gdata . health . service . HealthService ( ) <EOL> self . health . ClientLogin ( username , password , source = '<STR_LIT>' ) <EOL> self . profile_list_feed = self . health . GetProfileListFeed ( ) <EOL> def testGetProfileListFeed ( self ) : <EOL> self . assert_ ( isinstance ( self . profile_list_feed , <EOL> gdata . health . ProfileListFeed ) ) <EOL> self . assertEqual ( self . profile_list_feed . id . text , <EOL> '<STR_LIT>' ) <EOL> first_entry = self . profile_list_feed . entry [ <NUM_LIT:0> ] <EOL> self . assert_ ( isinstance ( first_entry , gdata . health . ProfileListEntry ) ) <EOL> self . assert_ ( first_entry . GetProfileId ( ) is not None ) <EOL> self . assert_ ( first_entry . GetProfileName ( ) is not None ) <EOL> query = gdata . health . service . HealthProfileListQuery ( ) <EOL> profile_list = self . health . GetProfileListFeed ( query ) <EOL> self . assertEqual ( first_entry . GetProfileId ( ) , <EOL> profile_list . entry [ <NUM_LIT:0> ] . GetProfileId ( ) ) <EOL> self . assertEqual ( profile_list . id . text , <EOL> '<STR_LIT>' ) <EOL> class H9QueryProfileListTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . h9 = gdata . health . service . HealthService ( use_h9_sandbox = True ) <EOL> self . h9 . ClientLogin ( username , password , source = '<STR_LIT>' ) <EOL> self . profile_list_feed = self . h9 . GetProfileListFeed ( ) <EOL> def testGetProfileListFeed ( self ) : <EOL> self . assert_ ( isinstance ( self . profile_list_feed , <EOL> gdata . health . ProfileListFeed ) ) <EOL> self . assertEqual ( self . profile_list_feed . id . text , <EOL> '<STR_LIT>' ) <EOL> first_entry = self . profile_list_feed . entry [ <NUM_LIT:0> ] <EOL> self . assert_ ( isinstance ( first_entry , gdata . health . ProfileListEntry ) ) <EOL> self . assert_ ( first_entry . GetProfileId ( ) is not None ) <EOL> self . assert_ ( first_entry . GetProfileName ( ) is not None ) <EOL> query = gdata . health . service . HealthProfileListQuery ( ) <EOL> profile_list = self . h9 . GetProfileListFeed ( query ) <EOL> self . assertEqual ( first_entry . GetProfileId ( ) , <EOL> profile_list . entry [ <NUM_LIT:0> ] . GetProfileId ( ) ) <EOL> self . assertEqual ( profile_list . id . text , <EOL> '<STR_LIT>' ) <EOL> class HealthQueryProfileTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . health = gdata . health . service . HealthService ( ) <EOL> self . health . ClientLogin ( username , password , source = '<STR_LIT>' ) <EOL> self . profile_list_feed = self . health . GetProfileListFeed ( ) <EOL> self . profile_id = self . profile_list_feed . entry [ <NUM_LIT:0> ] . GetProfileId ( ) <EOL> def testGetProfileFeed ( self ) : <EOL> feed = self . health . GetProfileFeed ( profile_id = self . profile_id ) <EOL> self . assert_ ( isinstance ( feed , gdata . health . ProfileFeed ) ) <EOL> self . assert_ ( isinstance ( feed . entry [ <NUM_LIT:0> ] . ccr , gdata . health . Ccr ) ) <EOL> def testGetProfileFeedByQuery ( self ) : <EOL> query = gdata . health . service . HealthProfileQuery ( <EOL> projection = '<STR_LIT>' , profile_id = self . profile_id ) <EOL> feed = self . health . GetProfileFeed ( query = query ) <EOL> self . assert_ ( isinstance ( feed , gdata . health . ProfileFeed ) ) <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr is not None ) <EOL> def testGetProfileDigestFeed ( self ) : <EOL> query = gdata . health . service . HealthProfileQuery ( <EOL> projection = '<STR_LIT>' , profile_id = self . profile_id , <EOL> params = { '<STR_LIT>' : '<STR_LIT:true>' } ) <EOL> feed = self . health . GetProfileFeed ( query = query ) <EOL> self . assertEqual ( len ( feed . entry ) , <NUM_LIT:1> ) <EOL> def testGetMedicationsAndConditions ( self ) : <EOL> query = gdata . health . service . HealthProfileQuery ( <EOL> projection = '<STR_LIT>' , profile_id = self . profile_id , <EOL> params = { '<STR_LIT>' : '<STR_LIT:true>' } , categories = [ '<STR_LIT>' ] ) <EOL> feed = self . health . GetProfileFeed ( query = query ) <EOL> self . assertEqual ( len ( feed . entry ) , <NUM_LIT:1> ) <EOL> if feed . entry [ <NUM_LIT:0> ] . ccr . GetMedications ( ) is not None : <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr . GetMedications ( ) [ <NUM_LIT:0> ] is not None ) <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr . GetConditions ( ) [ <NUM_LIT:0> ] is not None ) <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr . GetAllergies ( ) is None ) <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr . GetAlerts ( ) is None ) <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr . GetResults ( ) is None ) <EOL> class H9QueryProfileTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . h9 = gdata . health . service . HealthService ( use_h9_sandbox = True ) <EOL> self . h9 . ClientLogin ( username , password , source = '<STR_LIT>' ) <EOL> self . profile_list_feed = self . h9 . GetProfileListFeed ( ) <EOL> self . profile_id = self . profile_list_feed . entry [ <NUM_LIT:0> ] . GetProfileId ( ) <EOL> def testGetProfileFeed ( self ) : <EOL> feed = self . h9 . GetProfileFeed ( profile_id = self . profile_id ) <EOL> self . assert_ ( isinstance ( feed , gdata . health . ProfileFeed ) ) <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr is not None ) <EOL> def testGetProfileFeedByQuery ( self ) : <EOL> query = gdata . health . service . HealthProfileQuery ( <EOL> service = '<STR_LIT>' , projection = '<STR_LIT>' , profile_id = self . profile_id ) <EOL> feed = self . h9 . GetProfileFeed ( query = query ) <EOL> self . assert_ ( isinstance ( feed , gdata . health . ProfileFeed ) ) <EOL> self . assert_ ( feed . entry [ <NUM_LIT:0> ] . ccr is not None ) <EOL> class HealthNoticeTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . health = gdata . health . service . HealthService ( ) <EOL> self . health . ClientLogin ( username , password , source = '<STR_LIT>' ) <EOL> self . profile_list_feed = self . health . GetProfileListFeed ( ) <EOL> self . profile_id = self . profile_list_feed . entry [ <NUM_LIT:0> ] . GetProfileId ( ) <EOL> def testSendNotice ( self ) : <EOL> subject_line = '<STR_LIT>' <EOL> body = '<STR_LIT>' <EOL> ccr_xml = test_data . HEALTH_CCR_NOTICE_PAYLOAD <EOL> created_entry = self . health . SendNotice ( subject_line , <EOL> body , <EOL> ccr = ccr_xml , <EOL> profile_id = self . profile_id ) <EOL> self . assertEqual ( created_entry . title . text , subject_line ) <EOL> self . assertEqual ( created_entry . content . text , body ) <EOL> self . assertEqual ( created_entry . content . type , '<STR_LIT:html>' ) <EOL> problem = created_entry . ccr . GetProblems ( ) [ <NUM_LIT:0> ] <EOL> problem_desc = problem . FindChildren ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> name = problem_desc . FindChildren ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( name . text , '<STR_LIT>' ) <EOL> class H9NoticeTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . h9 = gdata . health . service . HealthService ( use_h9_sandbox = True ) <EOL> self . h9 . ClientLogin ( username , password , source = '<STR_LIT>' ) <EOL> self . profile_list_feed = self . h9 . GetProfileListFeed ( ) <EOL> self . profile_id = self . profile_list_feed . entry [ <NUM_LIT:0> ] . GetProfileId ( ) <EOL> def testSendNotice ( self ) : <EOL> subject_line = '<STR_LIT>' <EOL> body = '<STR_LIT>' <EOL> ccr_xml = test_data . HEALTH_CCR_NOTICE_PAYLOAD <EOL> created_entry = self . h9 . SendNotice ( subject_line , body , ccr = ccr_xml , <EOL> profile_id = self . profile_id ) <EOL> self . assertEqual ( created_entry . title . text , subject_line ) <EOL> self . assertEqual ( created_entry . content . text , body ) <EOL> self . assertEqual ( created_entry . content . type , '<STR_LIT:html>' ) <EOL> problem = created_entry . ccr . GetProblems ( ) [ <NUM_LIT:0> ] <EOL> problem_desc = problem . FindChildren ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> name = problem_desc . FindChildren ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( name . text , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> username = raw_input ( '<STR_LIT>' ) <EOL> password = getpass . getpass ( ) <EOL> unittest . main ( ) </s>
