def test_get_original_group_migrated(self): found_group = {"id": "/dev/foo", "apps": [], "groups": []} with application.test_request_context("/v2/groups//foo", method="GET") as ctx: with RequestsMock() as rsps: rsps.add( method="GET", url=conf.MARATHON_ADDRESSES[0] + "/v2/groups//dev/foo", body=json.dumps(found_group), status=200, ) ctx.request.user = self.user request = Request(ctx.request) group = request._get_original_group(self.user, "/foo") self.assertTrue(isinstance(group, AsgardAppGroup)) self.assertEqual(AsgardAppGroup.from_json(found_group), group)
def test_get_original_group_not_found(self): """ Tenta buscar um grupo que não existe. """ with application.test_request_context('/v2/groups//not-found', method='GET') as ctx: with RequestsMock() as rsps: rsps.add(method='GET', url=conf.MARATHON_ADDRESSES[0] + '/v2/groups//dev/not-found', status=404) ctx.request.user = self.user request = Request(ctx.request) group = request._get_original_group(self.user, "/not-found") self.assertEqual( AsgardAppGroup( MarathonGroup.from_json({"id": "/dev/not-found"})), group)