def testToAndFromString(self): entry = webmastertools.SitesEntry( indexed=webmastertools.Indexed(text='true'), crawled=webmastertools.Crawled(text='2008-09-14T08:59:28.000'), geolocation=webmastertools.GeoLocation(text='US'), preferred_domain=webmastertools.PreferredDomain(text='none'), crawl_rate=webmastertools.CrawlRate(text='normal'), enhanced_image_search=webmastertools.EnhancedImageSearch( text='true'), verified=webmastertools.Verified(text='false'), ) self.assert_(entry.indexed.text == 'true') self.assert_(entry.crawled.text == '2008-09-14T08:59:28.000') self.assert_(entry.geolocation.text == 'US') self.assert_(entry.preferred_domain.text == 'none') self.assert_(entry.crawl_rate.text == 'normal') self.assert_(entry.enhanced_image_search.text == 'true') self.assert_(entry.verified.text == 'false') new_entry = webmastertools.SitesEntryFromString(entry.ToString()) self.assert_(new_entry.indexed.text == 'true') self.assert_(new_entry.crawled.text == '2008-09-14T08:59:28.000') self.assert_(new_entry.geolocation.text == 'US') self.assert_(new_entry.preferred_domain.text == 'none') self.assert_(new_entry.crawl_rate.text == 'normal') self.assert_(new_entry.enhanced_image_search.text == 'true') self.assert_(new_entry.verified.text == 'false')
def UpdateEnhancedImageSearch(self, site_uri, enhanced_image_search, uri=SITE_TEMPLATE, url_params=None, escape_params=True, converter=None): """Updates enhanced image search setting of a site. Args: site_uri: str URI of which site to add sitemap for. enhanced_image_search: str The enhanced image search setting for a site. Valid values are 'true', and 'false'. uri: str (optional) URI template to update a site. Default SITE_TEMPLATE. url_params: dict (optional) Additional URL parameters to be included in the insertion request. escape_params: boolean (optional) If true, the url_parameters will be escaped before they are included in the request. converter: func (optional) Function which is executed on the server's response before it is returned. Usually this is a function like SitemapsEntryFromString which will parse the response and turn it into an object. Returns: If converter is defined, the results of running converter on the server's response. Otherwise, it will be a SitesEntry object. """ site_entry = webmastertools.SitesEntry( atom_id=atom.Id(text=site_uri), category=atom.Category( scheme='http://schemas.google.com/g/2005#kind', term= 'http://schemas.google.com/webmasters/tools/2007#sites-info'), enhanced_image_search=webmastertools.EnhancedImageSearch( text=enhanced_image_search)) response = self.Put(site_entry, uri % urllib.quote_plus(site_uri), url_params=url_params, escape_params=escape_params, converter=converter) if not converter and isinstance(response, atom.Entry): return webmastertools.SitesEntryFromString(response.ToString()) return response
def setUp(self): self.enhanced_image_search = webmastertools.EnhancedImageSearch()