Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_graphene():
client = Client(schema.schema)
executed = client.execute('{ test }')
assert executed == {
'data': {
'test': 'test'
}
def create_app(self):
app = create_app('testing')
self.base_url = 'https://127.0.0.1:5000/mrm'
self.headers = {'content-type': 'application/json'}
self.client = Client(schema)
return app
def getbibtexmappings():
bibtextypes = {}
for metatype in schema.loadTypesFromDB():
for bibtextype in metatype.get("bibtexmapping").split(";"):
if bibtextype:
metatype_name = metatype.getName()
bibtextypes[bibtextype] = bibtextypes.get(bibtextype, []) + [metatype_name]
for bibtextype in bibtextypes:
if len(bibtextypes[bibtextype]) == 1:
bibtextypes[bibtextype] = bibtextypes[bibtextype][-1]
elif len(bibtextypes[bibtextype]) > 1:
logg.error("bibtex import: ambiguous mapping for bibtex type '%s': %s - choosing last one",
bibtextype, bibtextypes[bibtextype])
bibtextypes[bibtextype] = bibtextypes[bibtextype][-1]
return bibtextypes
def init_modules():
"""init modules with own init function"""
from export import oaisets
if config.getboolean("oai.activate", False):
oaisets.init()
from export import exportutils
exportutils.init()
from schema import schema
schema.init()
from core import xmlnode
# xmlnode.init()
from core import auth
auth.init()
from export import exportutils
exportutils.init()
def get_test_app():
app = Flask(__name__)
app.debug = True
app.add_url_rule('/graphql', 'graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
app.add_url_rule('/', 'index', view_func=index_view,)
return app
def parse(query, source, page):
execution = schema.execute(query, args={'page': page, 'source': source})
if execution.errors:
raise Exception(execution.errors[0])
return execution.data
def check_masks_of_mdt(mdt):
for mask in mdt.masks:
print("-" * 80)
print(u"checking mask {} of mdt {}".format(mask.name, mdt.name))
metadatatypes.checkMask(mask, fix=args.fix, verbose=1, show_unused=1)
app.add_url_rule(
'/',
view_func=GraphQLView.as_view(
'graphql',
schema=schema,
graphiql=False
)
)
app.add_url_rule(
'/graphiql',
view_func=GraphQLView.as_view(
'graphiql',
schema=schema,
graphiql=True
)
)
return app
from database.base import db_session
from flask import Flask
from flask_graphql import GraphQLView
from schema import schema
app = Flask(__name__)
app.add_url_rule(
'/graphql',
view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
if __name__ == '__main__':
app.run(threaded=True, debug=True)
async def graphql_view(request):
payload = await request.json()
response = await schema.execute(payload.get('query', ''), return_promise=True)
data = {}
if response.errors:
data['errors'] = [format_error(e) for e in response.errors]
if response.data:
data['data'] = response.data
jsondata = json.dumps(data,)
return web.Response(text=jsondata, headers={'Content-Type': 'application/json'})