def get_profile(self): if self.get('profile_id') > 0: if self.profile_obj is None: self.profile_obj = Profile(Campaign.connection).find_one(self.get('profile_id'), self.get('advertiser_id')) else: new_profile = Profile(Campaign.connection) new_profile['advertiser_id'] = self.get('advertiser_id') new_profile.create() self.profile_obj = new_profile self['profile_id'] = new_profile.get('id') return self.profile_obj
def get_profile(self): if self.get('profile_id') > 0: if self.profile_obj is None: self.profile_obj = Profile(Campaign.connection).find_one( self.get('profile_id'), self.get('advertiser_id')) else: new_profile = Profile(Campaign.connection) new_profile['advertiser_id'] = self.get('advertiser_id') new_profile.create() self.profile_obj = new_profile self['profile_id'] = new_profile.get('id') return self.profile_obj
def testCreate(self): profile = Profile(ProfileTest.conn) profile['advertiser_id'] = 136402 profile['deal_targets'] = [{'id': 1999}] profile['domain_targets'] = [{'domain': 'www.espn.com'}] result = profile.create() assert result == profile.get('id')