def test_fetch_notfound(self): """LXDAPIException is raised on bogus profile fetches.""" def not_found(request, context): context.status_code = 404 return json.dumps({ 'type': 'error', 'error': 'Not found', 'error_code': 404}) self.add_rule({ 'text': not_found, 'method': 'GET', 'url': r'^http://pylxd.test/1.0/profiles/an-profile$', }) an_profile = models.Profile(self.client, name='an-profile') self.assertRaises(exceptions.LXDAPIException, an_profile.sync)
def test_fetch_error(self): """LXDAPIException is raised on fetch error.""" def error(request, context): context.status_code = 500 return json.dumps({ "type": "error", "error": "Not found", "error_code": 500 }) self.add_rule({ "text": error, "method": "GET", "url": r"^http://pylxd.test/1.0/profiles/an-profile$", }) an_profile = models.Profile(self.client, name="an-profile") self.assertRaises(exceptions.LXDAPIException, an_profile.sync)