def test_store_services(self): """ Test saving embedly services to site annotation """ portal = self.layer['portal'] storage = IAnnotations(portal) self.assertEqual(storage.get('collective.embedly.services'), None) update_services() res = urllib2.urlopen('http://api.embed.ly/v1/api/services/python') list_exp = [] for service in json.loads(res.read()): list_exp.append('|'.join(service.get('regex', []))) self.assertEqual(storage.get('collective.embedly.services'), '|'.join(list_exp))
def __call__(self): if update_services(): return "Services list updated." else: return "Problems with connection to embed.ly. Check internet connection."