248920f
From f96278906447fe2b3aa15d6fb0a0dc28e6dddf83 Mon Sep 17 00:00:00 2001
248920f
From: Clement Verna <cverna@tutanota.com>
248920f
Date: Wed, 18 Nov 2020 21:08:24 +0100
248920f
Subject: [PATCH] Remove Graphql for packaging
248920f
248920f
Signed-off-by: Clement Verna <cverna@tutanota.com>
248920f
248920f
diff --git a/bodhi/server/graphql_schemas.py b/bodhi/server/graphql_schemas.py
248920f
deleted file mode 100644
248920f
index 2acf57f7..00000000
248920f
--- a/bodhi/server/graphql_schemas.py
248920f
+++ /dev/null
248920f
@@ -1,62 +0,0 @@
248920f
-# Copyright © 2020 Red Hat Inc., and others.
248920f
-#
248920f
-# This file is part of Bodhi.
248920f
-#
248920f
-# This program is free software; you can redistribute it and/or
248920f
-# modify it under the terms of the GNU General Public License
248920f
-# as published by the Free Software Foundation; either version 2
248920f
-# of the License, or (at your option) any later version.
248920f
-#
248920f
-# This program is distributed in the hope that it will be useful,
248920f
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
248920f
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
248920f
-# GNU General Public License for more details.
248920f
-#
248920f
-# You should have received a copy of the GNU General Public License
248920f
-# along with this program; if not, write to the Free Software
248920f
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
248920f
-"""Defines schemas related to GraphQL objects."""
248920f
-from graphene import relay, Field, String
248920f
-from graphene_sqlalchemy import SQLAlchemyObjectType
248920f
-
248920f
-from bodhi.server.models import (
248920f
-    Release as ReleaseModel,
248920f
-    Update as UpdateModel,
248920f
-    BuildrootOverride as BuildrootOverrideModel
248920f
-)
248920f
-
248920f
-
248920f
-class Release(SQLAlchemyObjectType):
248920f
-    """Type object representing a distribution release from bodhi.server.models like Fedora 27."""
248920f
-
248920f
-    class Meta:
248920f
-        """Allow to set different options to the class."""
248920f
-
248920f
-        model = ReleaseModel
248920f
-        interfaces = (relay.Node, )
248920f
-    state = Field(String)
248920f
-    package_manager = Field(String)
248920f
-
248920f
-
248920f
-class Update(SQLAlchemyObjectType):
248920f
-    """Type object representing an update from bodhi.server.models."""
248920f
-
248920f
-    class Meta:
248920f
-        """Allow to set different options to the class."""
248920f
-
248920f
-        model = UpdateModel
248920f
-        interfaces = (relay.Node, )
248920f
-    status = Field(String)
248920f
-    request = Field(String)
248920f
-    date_approved = Field(String)
248920f
-
248920f
-
248920f
-class BuildrootOverride(SQLAlchemyObjectType):
248920f
-    """Type object representing an update from bodhi.server.models."""
248920f
-
248920f
-    class Meta:
248920f
-        """Allow to set different options to the class."""
248920f
-
248920f
-        model = BuildrootOverrideModel
248920f
-        interfaces = (relay.Node, )
248920f
-    submitter = Field(String)
248920f
diff --git a/bodhi/server/services/graphql.py b/bodhi/server/services/graphql.py
248920f
deleted file mode 100644
248920f
index 1d68f320..00000000
248920f
--- a/bodhi/server/services/graphql.py
248920f
+++ /dev/null
248920f
@@ -1,179 +0,0 @@
248920f
-# Copyright © 2020 Red Hat Inc., and others.
248920f
-#
248920f
-# This file is part of Bodhi.
248920f
-#
248920f
-# This program is free software; you can redistribute it and/or
248920f
-# modify it under the terms of the GNU General Public License
248920f
-# as published by the Free Software Foundation; either version 2
248920f
-# of the License, or (at your option) any later version.
248920f
-#
248920f
-# This program is distributed in the hope that it will be useful,
248920f
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
248920f
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
248920f
-# GNU General Public License for more details.
248920f
-#
248920f
-# You should have received a copy of the GNU General Public License
248920f
-# along with this program; if not, write to the Free Software
248920f
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
248920f
-"""Defines API endpoints related to GraphQL objects."""
248920f
-import graphene
248920f
-from cornice import Service
248920f
-from webob_graphql import serve_graphql_request
248920f
-
248920f
-from bodhi.server.config import config
248920f
-from bodhi.server.models import Build as BuildModel, User as UserModel
248920f
-from bodhi.server.graphql_schemas import (
248920f
-    Release,
248920f
-    ReleaseModel,
248920f
-    Update,
248920f
-    UpdateModel,
248920f
-    BuildrootOverride,
248920f
-    BuildrootOverrideModel
248920f
-)
248920f
-
248920f
-graphql = Service(name='graphql', path='/graphql', description='graphql service')
248920f
-
248920f
-
248920f
-@graphql.get()
248920f
-@graphql.post()
248920f
-def graphql_get(request):
248920f
-    """
248920f
-    Perform a GET request.
248920f
-
248920f
-    Args:
248920f
-        request (pyramid.Request): The current request.
248920f
-    Returns:
248920f
-        The GraphQL response to the request.
248920f
-    """
248920f
-    context = {'session': request.session}
248920f
-    return serve_graphql_request(
248920f
-        request, schema, graphiql_enabled=config.get('graphiql_enabled'),
248920f
-        context_value=context)
248920f
-
248920f
-
248920f
-class Query(graphene.ObjectType):
248920f
-    """Allow querying objects."""
248920f
-
248920f
-    allReleases = graphene.List(Release)
248920f
-    getReleases = graphene.Field(
248920f
-        lambda: graphene.List(Release), name=graphene.String(),
248920f
-        id_prefix=graphene.String(), composed_by_bodhi=graphene.Boolean(),
248920f
-        state=graphene.String())
248920f
-
248920f
-    getUpdates = graphene.Field(
248920f
-        lambda: graphene.List(Update), stable_karma=graphene.Int(),
248920f
-        stable_days=graphene.Int(), unstable_karma=graphene.Int(),
248920f
-        status=graphene.String(), request=graphene.String(),
248920f
-        pushed=graphene.Boolean(), critpath=graphene.Boolean(),
248920f
-        date_approved=graphene.String(), alias=graphene.String(),
248920f
-        user_id=graphene.Int(), release_name=graphene.String())
248920f
-
248920f
-    getBuildrootOverrides = graphene.Field(
248920f
-        lambda: graphene.List(BuildrootOverride),
248920f
-        submission_date=graphene.DateTime(),
248920f
-        expiration_date=graphene.DateTime(),
248920f
-        build_nvr=graphene.String(),
248920f
-        submitter_username=graphene.String())
248920f
-
248920f
-    def resolve_allReleases(self, info):
248920f
-        """Answer Queries by fetching data from the Schema."""
248920f
-        query = Release.get_query(info)  # SQLAlchemy query
248920f
-        return query.all()
248920f
-
248920f
-    def resolve_getReleases(self, info, **args):
248920f
-        """Answer Release queries with a given argument."""
248920f
-        query = Release.get_query(info)
248920f
-
248920f
-        id_prefix = args.get("id_prefix")
248920f
-        if id_prefix is not None:
248920f
-            query = query.filter(ReleaseModel.id_prefix == id_prefix)
248920f
-
248920f
-        name = args.get("name")
248920f
-        if name is not None:
248920f
-            query = query.filter(ReleaseModel.name == name)
248920f
-
248920f
-        composed_by_bodhi = args.get("composed_by_bodhi")
248920f
-        if composed_by_bodhi is not None:
248920f
-            query = query.filter(ReleaseModel.composed_by_bodhi == composed_by_bodhi)
248920f
-
248920f
-        state = args.get("state")
248920f
-        if state is not None:
248920f
-            query = query.filter(ReleaseModel.state == state)
248920f
-
248920f
-        return query.all()
248920f
-
248920f
-    def resolve_getUpdates(self, info, **args):
248920f
-        """Answer Release queries with a given argument."""
248920f
-        query = Update.get_query(info)
248920f
-
248920f
-        stable_karma = args.get("stable_karma")
248920f
-        if stable_karma is not None:
248920f
-            query = query.filter(UpdateModel.stable_karma == stable_karma)
248920f
-
248920f
-        stable_days = args.get("stable_days")
248920f
-        if stable_days is not None:
248920f
-            query = query.filter(UpdateModel.stable_days == stable_days)
248920f
-
248920f
-        unstable_karma = args.get("unstable_karma")
248920f
-        if unstable_karma is not None:
248920f
-            query = query.filter(UpdateModel.unstable_karma == unstable_karma)
248920f
-
248920f
-        status = args.get("status")
248920f
-        if status is not None:
248920f
-            query = query.filter(UpdateModel.status == status)
248920f
-
248920f
-        request = args.get("request")
248920f
-        if request is not None:
248920f
-            query = query.filter(UpdateModel.request == request)
248920f
-
248920f
-        pushed = args.get("pushed")
248920f
-        if pushed is not None:
248920f
-            query = query.filter(UpdateModel.pushed == pushed)
248920f
-
248920f
-        critpath = args.get("critpath")
248920f
-        if critpath is not None:
248920f
-            query = query.filter(UpdateModel.critpath == critpath)
248920f
-
248920f
-        date_approved = args.get("date_approved")
248920f
-        if date_approved is not None:
248920f
-            query = query.filter(UpdateModel.date_approved == date_approved)
248920f
-
248920f
-        alias = args.get("alias")
248920f
-        if alias is not None:
248920f
-            query = query.filter(UpdateModel.alias == alias)
248920f
-
248920f
-        user_id = args.get("user_id")
248920f
-        if user_id is not None:
248920f
-            query = query.filter(UpdateModel.user_id == user_id)
248920f
-
248920f
-        release_name = args.get("release_name")
248920f
-        if release_name is not None:
248920f
-            query = query.join(UpdateModel.release).filter(ReleaseModel.name == release_name)
248920f
-
248920f
-        return query.all()
248920f
-
248920f
-    def resolve_getBuildrootOverrides(self, info, **args):
248920f
-        """Answer Release queries with a given argument."""
248920f
-        query = BuildrootOverride.get_query(info)
248920f
-
248920f
-        submission_date = args.get("submission_date")
248920f
-        if submission_date is not None:
248920f
-            query = query.filter(BuildrootOverrideModel.submission_date == submission_date)
248920f
-
248920f
-        expiration_date = args.get("expiration_date")
248920f
-        if expiration_date is not None:
248920f
-            query = query.filter(BuildrootOverrideModel.expiration_date == expiration_date)
248920f
-
248920f
-        build_nvr = args.get("build_nvr")
248920f
-        if build_nvr is not None:
248920f
-            query = query.join(BuildrootOverrideModel.build).filter(BuildModel.nvr == build_nvr)
248920f
-
248920f
-        submitter_username = args.get("submitter_username")
248920f
-        if submitter_username is not None:
248920f
-            query = query.join(BuildrootOverrideModel.submitter).filter(
248920f
-                UserModel.name == submitter_username)
248920f
-
248920f
-        return query.all()
248920f
-
248920f
-
248920f
-schema = graphene.Schema(query=Query)
248920f
diff --git a/bodhi/tests/server/services/test_graphql.py b/bodhi/tests/server/services/test_graphql.py
248920f
deleted file mode 100644
248920f
index 3bd9e29d..00000000
248920f
--- a/bodhi/tests/server/services/test_graphql.py
248920f
+++ /dev/null
248920f
@@ -1,251 +0,0 @@
248920f
-# Copyright © 2020 Red Hat, Inc. and others.
248920f
-#
248920f
-# This file is part of Bodhi.
248920f
-#
248920f
-# This program is free software; you can redistribute it and/or
248920f
-# modify it under the terms of the GNU General Public License
248920f
-# as published by the Free Software Foundation; either version 2
248920f
-# of the License, or (at your option) any later version.
248920f
-#
248920f
-# This program is distributed in the hope that it will be useful,
248920f
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
248920f
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
248920f
-# GNU General Public License for more details.
248920f
-#
248920f
-# You should have received a copy of the GNU General Public License
248920f
-# along with this program; if not, write to the Free Software
248920f
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
248920f
-import datetime
248920f
-
248920f
-from graphene.test import Client
248920f
-
248920f
-from bodhi.tests.server import base
248920f
-from bodhi.server.services.graphql import schema
248920f
-from bodhi.server import models
248920f
-
248920f
-
248920f
-class TestGraphQLService(base.BasePyTestCase):
248920f
-    """This class contains tests for a /graphql endpoint."""
248920f
-    def test_get(self):
248920f
-        """Ensure that a GraphQL response is returned"""
248920f
-        res = self.app.get('/graphql?query={%0A%20 allReleases{%0A%20%20%20 name%0A%20 }%0A}')
248920f
-        assert res.body == b'{"data":{"allReleases":[{"name":"F17"}]}}'
248920f
-
248920f
-    def test_allReleases(self):
248920f
-        """Testing allReleases."""
248920f
-        base.BaseTestCaseMixin.create_release(self, version='22')
248920f
-        client = Client(schema)
248920f
-        self.db.commit()
248920f
-
248920f
-        executed = client.execute("""{  allReleases{  name  }}""")
248920f
-        assert executed == {
248920f
-            "data": {
248920f
-                "allReleases": [{
248920f
-                    "name": "F17"
248920f
-                }, {
248920f
-                    "name": "F22"
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-    def test_enumfields(self):
248920f
-        """Testing enum fields on releases."""
248920f
-        base.BaseTestCaseMixin.create_release(self, version='22')
248920f
-        client = Client(schema)
248920f
-        self.db.commit()
248920f
-
248920f
-        executed = client.execute("""{  allReleases{  state    packageManager  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'allReleases': [{
248920f
-                    'packageManager': 'unspecified',
248920f
-                    'state': 'current'
248920f
-                }, {
248920f
-                    'packageManager': 'unspecified',
248920f
-                    'state': 'current'
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-    def test_getReleases(self):
248920f
-        """Testing getReleases query."""
248920f
-        base.BaseTestCaseMixin.create_release(self, version='22')
248920f
-        client = Client(schema)
248920f
-        self.db.commit()
248920f
-
248920f
-        executed = client.execute("""{  getReleases(idPrefix: "FEDORA"){  name  }}""")
248920f
-        assert executed == {
248920f
-            "data": {
248920f
-                "getReleases": [{
248920f
-                    "name": "F17"
248920f
-                }, {
248920f
-                    "name": "F22"
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getReleases(name: "F17"){  id  }}""")
248920f
-        assert executed == {
248920f
-            "data": {
248920f
-                "getReleases": [{
248920f
-                    "id": "UmVsZWFzZTox"
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getReleases(composedByBodhi: true){  name  }}""")
248920f
-        assert executed == {
248920f
-            "data": {
248920f
-                "getReleases": [{
248920f
-                    "name": "F17"
248920f
-                }, {
248920f
-                    "name": "F22"
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute(
248920f
-            """{  getReleases(state: "current", composedByBodhi: true){  name  }}""")
248920f
-        assert executed == {
248920f
-            "data": {
248920f
-                "getReleases": [{
248920f
-                    "name": "F17"
248920f
-                }, {
248920f
-                    "name": "F22"
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-    def test_getUpdates(self):
248920f
-        """Testing getUpdates query."""
248920f
-        release = base.BaseTestCaseMixin.create_release(self, version='22')
248920f
-        self.create_update(build_nvrs=['TurboGears-2.1-1.el5'],
248920f
-                           release_name=release.name)
248920f
-        up2 = self.create_update(build_nvrs=['freetype-2.10.2-1.fc32'],
248920f
-                                 release_name=release.name)
248920f
-        up2.alias = "FEDORA-2020-3223f9ec8b"
248920f
-        up2.stable_days = 1
248920f
-        up2.date_approved = datetime.datetime(2019, 10, 13, 16, 16, 22, 438484)
248920f
-        self.db.commit()
248920f
-        client = Client(schema)
248920f
-
248920f
-        executed = client.execute("""{  getUpdates(stableDays: 1,
248920f
-                                  dateApproved: "2019-10-13 16:16:22.438484")
248920f
-                                  {  alias  request  unstableKarma  }}""")
248920f
-        assert executed == {
248920f
-            "data": {
248920f
-                "getUpdates": [{
248920f
-                    "alias": "FEDORA-2020-3223f9ec8b",
248920f
-                    "request": "testing",
248920f
-                    "unstableKarma": -3
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getUpdates(stableKarma: 3, status: "pending",
248920f
-                                  critpath: false, pushed: false, request:"testing"){  stableDays
248920f
-                                  userId  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'getUpdates': [{
248920f
-                    'stableDays': 0,
248920f
-                    'userId': 1
248920f
-                }, {
248920f
-                    'stableDays': 0,
248920f
-                    'userId': 1
248920f
-                }, {
248920f
-                    'stableDays': 1,
248920f
-                    'userId': 1
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getUpdates(stableDays: 1,
248920f
-                                  unstableKarma: -3, alias: "FEDORA-2020-3223f9ec8b")
248920f
-                                  {  dateApproved  request  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'getUpdates': [{
248920f
-                    'dateApproved': "2019-10-13 16:16:22.438484",
248920f
-                    'request': 'testing'
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getUpdates(critpath: false, stableDays: 1,
248920f
-                                  userId: 1){  request    unstableKarma  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'getUpdates': [{
248920f
-                    'request': 'testing',
248920f
-                    'unstableKarma': -3,
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getUpdates(releaseName: "F22"){  request  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'getUpdates': [{
248920f
-                    'request': 'testing',
248920f
-                }, {
248920f
-                    'request': 'testing',
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-    def test_getBuildrootOverrides(self):
248920f
-        """Testing getBuildOverrides query."""
248920f
-        release = models.Release.get('F17')
248920f
-
248920f
-        package = models.RpmPackage(name='just-testing')
248920f
-        self.db.add(package)
248920f
-        build = models.RpmBuild(nvr='just-testing-1.0-2.fc17', package=package, release=release)
248920f
-        self.db.add(build)
248920f
-        another_user = models.User(name='aUser')
248920f
-        self.db.add(another_user)
248920f
-
248920f
-        expiration_date = datetime.datetime(2020, 10, 13, 16, 16, 22, 438484)
248920f
-        submission_date = datetime.datetime(2020, 10, 12, 16, 16, 22, 438484)
248920f
-
248920f
-        override = models.BuildrootOverride(build=build, submitter=another_user,
248920f
-                                            notes='Crazy! 😱',
248920f
-                                            expiration_date=expiration_date,
248920f
-                                            submission_date=submission_date)
248920f
-        self.db.add(override)
248920f
-        self.db.flush()
248920f
-        client = Client(schema)
248920f
-        self.db.commit()
248920f
-
248920f
-        executed = client.execute("""{  getBuildrootOverrides(buildNvr: "just-testing-1.0-2.fc17")
248920f
-                                  {  submissionDate  expirationDate  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'getBuildrootOverrides': [{
248920f
-                    'expirationDate': "2020-10-13T16:16:22.438484",
248920f
-                    'submissionDate': "2020-10-12T16:16:22.438484",
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getBuildrootOverrides(submissionDate: "2020-10-12T16:16:22.438484",
248920f
-                                  expirationDate: "2020-10-13T16:16:22.438484")
248920f
-                                  {  notes  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'getBuildrootOverrides': [{
248920f
-                    'notes': "Crazy! 😱"
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
-
248920f
-        executed = client.execute("""{  getBuildrootOverrides(submitterUsername: "aUser",
248920f
-                                  expirationDate: "2020-10-13T16:16:22.438484")
248920f
-                                  {  notes  }}""")
248920f
-        assert executed == {
248920f
-            'data': {
248920f
-                'getBuildrootOverrides': [{
248920f
-                    'notes': "Crazy! 😱"
248920f
-                }]
248920f
-            }
248920f
-        }
248920f
diff --git a/requirements.txt b/requirements.txt
248920f
index b66508b5..a7cf46df 100644
248920f
--- a/requirements.txt
248920f
+++ b/requirements.txt
248920f
@@ -10,9 +10,6 @@ dogpile.cache
248920f
 pyasn1-modules  # Due to an unfortunate dash in its name, installs break if pyasn1 is installed first
248920f
 fedora_messaging
248920f
 feedgen>=0.7.0
248920f
-graphene
248920f
-graphene-sqlalchemy
248920f
-koji
248920f
 jinja2
248920f
 markdown>=3.0
248920f
 prometheus_client
248920f
@@ -28,5 +25,4 @@ PyYAML
248920f
 simplemediawiki
248920f
 sqlalchemy
248920f
 waitress
248920f
-WebOb-GraphQL
248920f
 whitenoise
248920f
diff --git a/setup.py b/setup.py
248920f
index 1cb2f24b..c0269319 100644
248920f
--- a/setup.py
248920f
+++ b/setup.py
248920f
@@ -111,7 +111,7 @@ client_setup = {
248920f
     'keywords': 'fedora',
248920f
     'packages': client_pkgs,
248920f
     'include_package_data': False,
248920f
-    'install_requires': ['click', 'python-fedora >= 0.9.0', 'koji'],
248920f
+    'install_requires': ['click', 'python-fedora >= 0.9.0'],
248920f
     'entry_points': '''
248920f
         [console_scripts]
248920f
         bodhi = bodhi.client:cli
248920f
-- 
248920f
2.28.0
248920f