Exemplo n.º 1
0
__author__ = 'Jared Jorgensen'

from slickqaweb.app import app
from slickqaweb.model.testrunGroup import TestrunGroup
from slickqaweb.model.testrun import Testrun
from slickqaweb.model.serialize import deserialize_that
from slickqaweb.model.query import queryFor
from slickqaweb.utils import *
import datetime
from flask import request, g
from .standardResponses import JsonResponse, read_request
from bson import ObjectId
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, note
from mongoengine import ListField, ReferenceField

add_resource('/testrungroups', 'Add, update, and delete testrungroups.')


@app.route('/api/testrungroups')
@standard_query_parameters
@returns(ListField(ReferenceField(TestrunGroup)))
def get_testrungroups():
    """Query for testrungroups."""
    return JsonResponse(queryFor(TestrunGroup))

@app.route('/api/testrungroups/<testrungroup_id>')
@returns(TestrunGroup)
@argument_doc('testrungroup_id', "A Testrun Group's id (the string representation of a BSON ObjectId).")
def get_testrungroup_by_id(testrungroup_id):
    """Find a testrungroup by it's id."""
    return JsonResponse(TestrunGroup.objects(id=testrungroup_id).first())
Exemplo n.º 2
0
__author__ = 'jcorbett'

from slickqaweb.model.configuration import Configuration
from slickqaweb.model.query import queryFor
from slickqaweb.model.serialize import deserialize_that
from slickqaweb.app import app
from .standardResponses import JsonResponse, read_request
from flask import request
from bson import ObjectId
import mongoengine
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters

add_resource("/configurations", "Add, edit or remove configurations of different types.")

@app.route('/api/configurations')
@standard_query_parameters
@returns(mongoengine.ListField(mongoengine.ReferenceField(Configuration)))
def get_all_matching_configurations():
    """Query for and find configurations (like Environments)."""
    return JsonResponse(queryFor(Configuration))


@app.route('/api/configurations', methods=['POST'])
@accepts(Configuration)
@returns(Configuration)
def create_configuration():
    """Create a new configuration"""
    config = deserialize_that(read_request(), Configuration())
    config.save()
    return JsonResponse(config)
Exemplo n.º 3
0
__author__ = 'jcorbett'

from slickqaweb.app import app
from slickqaweb.model.dashboards import load_dashboard_type, load_dashboard_type_by_name, DashboardTypes, BaseDashboard
from slickqaweb.model.serialize import deserialize_that
from slickqaweb.model.query import queryFor
from flask import request, g
from .standardResponses import JsonResponse, read_request
from bson import ObjectId
from slickqaweb.utils import is_id
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, add_swagger_model
from mongoengine import ListField, EmbeddedDocumentField, ReferenceField

dashboard_resource = add_resource("/dashboards", "Create, modify, and delete dashboard configurations.")
dashboard_resource.subtypes[BaseDashboard] = []
for dashboard_type in DashboardTypes.values():
    dashboard_resource.subtypes[BaseDashboard].append(dashboard_type)


@app.route('/api/dashboards')
@standard_query_parameters
@returns(ListField(ReferenceField(BaseDashboard), help_text="It's actually a subclass of BaseDashboard."))
def get_dashboards():
    """Query for a list of dashboards."""
    args = request.args
    type = BaseDashboard
    if args.has_key('config-type'):
        args = args.to_dict()
        if args['config-type'] in DashboardTypes:
            type = DashboardTypes[args['config-type']]
        else:
Exemplo n.º 4
0
__author__ = 'Jared'

from slickqaweb.app import app
from slickqaweb.model.testPlan import TestPlan
from slickqaweb.model.serialize import deserialize_that
from slickqaweb.model.query import queryFor
from flask import request, g
from .standardResponses import JsonResponse, read_request
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, note
from mongoengine import ListField, ReferenceField

add_resource('/testplans', 'Add, update, and delete testplans.')


@app.route('/api/testplans')
@standard_query_parameters
@returns(ListField(ReferenceField(TestPlan)))
def get_testplans():
    """Query for existing testplans."""
    # for backwards compatibility
    args = request.args
    if args.has_key('projectid'):
        args = args.to_dict()
        args['project.id'] = request.args['projectid']
        del args['projectid']
    return JsonResponse(queryFor(TestPlan, args))

@app.route('/api/testplans/<testplan_id>')
@argument_doc('testplan_id', 'The id of the testplan (string representation of BSON ObjectId).')
def get_testplan_by_id(testplan_id):
    """Get a specific testplan by it's id."""
Exemplo n.º 5
0
__author__ = 'jcorbett'

from .standardResponses import JsonResponse, read_request
from slickqaweb.model.slickLogEvent import SlickLogEvent
from slickqaweb.app import app
from slickqaweb.model.query import queryFor
from slickqaweb.model.serialize import deserialize_that
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, note
from mongoengine import ListField, ReferenceField

from flask import g

add_resource("/slicklogevents", "Get slick audit log events.")


@app.route("/api/slicklogevents")
@standard_query_parameters
@returns(ListField(ReferenceField(SlickLogEvent)))
def get_events():
    """Query for slick log events."""
    return JsonResponse(queryFor(SlickLogEvent))

@app.route("/api/slicklogevents", methods=["POST"])
@accepts(SlickLogEvent)
@returns(SlickLogEvent)
def create_event():
    """Add a new slick log event."""
    new_log = deserialize_that(read_request(), SlickLogEvent())
    # set the user if one is logged in
    if (new_log.user is None or new_log.user == "" or new_log.user == "Anonymous") and g.user is not None:
        new_log.user = g.user.full_name + " <" + g.user.email + ">"
Exemplo n.º 6
0
__author__ = 'slambson'

from slickqaweb.app import app
from slickqaweb.model.testcase import Testcase
from slickqaweb.model.serialize import deserialize_that
from slickqaweb.model.query import queryFor
from flask import request, g
from .standardResponses import JsonResponse, read_request
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, note
from mongoengine import ListField, ReferenceField

add_resource('/testcases', 'Add, update, and delete testcases.')

# TODO: add error handling. Not sure how to handle that yet.
@app.route('/api/testcases')
@standard_query_parameters
@returns(ListField(ReferenceField(Testcase)))
def get_testcases():
    """Query for testcases."""
    args = request.args
    if args.has_key('projectid'):
        args = args.to_dict()
        args['project.id'] = request.args['projectid']
        del args['projectid']
    return JsonResponse(queryFor(Testcase, args))

@app.route('/api/testcases/<testcase_id>')
@returns(Testcase)
@argument_doc('testcase_id', 'The id of the testcase you are trying to access (string representation of BSON ObjectId).')
def get_testcase_by_id(testcase_id):
    """Retrieve a testcase by it's id."""
Exemplo n.º 7
0
__author__ = 'jcorbett'

from slickqaweb.app import app
from slickqaweb.model.systemConfiguration import load_system_configuration_type, SystemConfigurationTypes, BaseSystemConfiguration
from slickqaweb.model.serialize import deserialize_that
from slickqaweb.model.query import queryFor
from flask import request, g
from .standardResponses import JsonResponse, read_request
from bson import ObjectId
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, note
from mongoengine import ListField, EmbeddedDocumentField, ReferenceField

sysconfig_resource = add_resource("/system-configuration", "Create, modify, and delete slick system configurations.")

sysconfig_resource.subtypes[BaseSystemConfiguration] = []
for system_configuration_type in SystemConfigurationTypes.values():
    sysconfig_resource.subtypes[BaseSystemConfiguration].append(system_configuration_type)


@app.route('/api/system-configuration')
@standard_query_parameters
@argument_doc('config-type', 'A shortcut for querying for the configuration type.', paramtype='query')
@note("This method returns other types, but the values in BaseSystemConfiguration are guaranteed to be common.")
@returns(ListField(ReferenceField(BaseSystemConfiguration)))
def get_system_configurations():
    """Find various system configuration types."""
    args = request.args
    type = BaseSystemConfiguration
    if args.has_key('config-type'):
        args = args.to_dict()
        if args['config-type'] in SystemConfigurationTypes:
Exemplo n.º 8
0
__author__ = 'jcorbett'

from slickqaweb.app import app
from .standardResponses import JsonResponse
from slickqaweb.model.productVersion import ProductVersion
from apidocs import add_resource, returns, note
from mongoengine import ListField, ReferenceField

add_resource('/version', 'Get slick version information')

@app.route('/api/version')
@returns(ListField(ReferenceField(ProductVersion)))
@note("This returns an array, but right now it's guaranteed to only have one element in it, the slick version.")
def get_version():
    """Get the slick version"""
    slickversion = ProductVersion()
    slickversion.productName = "slick"
    slickversion.versionString = "3.0.0.0.0.0"
    return JsonResponse([slickversion,])
Exemplo n.º 9
0
from slickqaweb.model.configurationReference import ConfigurationReference
from slickqaweb import events
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, note
from mongoengine import ListField, ReferenceField, IntField, EmbeddedDocumentField, Q, connection
import logging
import sys

from bson import ObjectId
import types
import datetime
from mongoengine import Q
from flask import request, Response

__author__ = 'jcorbett'

add_resource('/results', 'Add, Update or delete results.')


def find_history(result):
    assert isinstance(result, Result)
    history = []

    # other results with the same Test, Testplan, Environment, Release
    try:
        query = {"testcase__testcaseId": result.testcase.testcaseId,
                 "recorded__lt":result.recorded}
        if hasattr(result, 'config') and result.config is not None:
            query['config__configId'] = result.config.configId
        else:
            query['config__exists'] = False
        if hasattr(result, 'release') and result.release is not None:
Exemplo n.º 10
0
__author__ = 'jcorbett'

from slickqaweb.app import app
from slickqaweb.model.userAccount import UserAccount
from .standardResponses import JsonResponse, read_request
from slickqaweb.model.query import queryFor
from flask import g, Response
from apidocs import add_resource, accepts, returns, argument_doc, standard_query_parameters, note
from mongoengine import ListField, ReferenceField
from slickqaweb.model.serialize import deserialize_that
from slickqaweb import events

add_resource('/users', 'Access user accounts.')


@app.route("/api/users")
@standard_query_parameters
@returns(ListField(ReferenceField(UserAccount)))
def get_users():
    """Query for user accounts."""
    return JsonResponse(queryFor(UserAccount))


@app.route("/api/users/<email>")
@returns(UserAccount)
@argument_doc('email', "The email address of the user you wish to recieve the account for, or current for the currently logged in user.")
@note("If you supply 'current' as the user's email address it will return the currently logged in user's account, or a 404 if no one is logged in.")
def get_current_user(email):
    """Retrieve a user account by their email address."""
    if "current" == email:
        if g.user is not None:
Exemplo n.º 11
0
__author__ = 'jcorbett'

from slickqaweb.app import app
from flask import request, Response
from bson import ObjectId
from slickqaweb.model.storedFile import StoredFile
from slickqaweb.model.fileChunk import FileChunk
from slickqaweb.model.serialize import deserialize_that
from .standardResponses import JsonResponse, read_request
from hashlib import md5
import re
import logging
from apidocs import add_resource, accepts, returns, argument_doc, note
from mongoengine import ListField, EmbeddedDocumentField, ReferenceField, BinaryField

add_resource('/files', 'Upload, or Download files on slick.')

@app.route("/api/files/<file_id>")
@argument_doc('file_id', 'The id (string representation of the ObjectID) of the stored file.')
@returns(StoredFile)
def get_stored_file(file_id):
    """Get the "stored file" or the summary about the file."""
    return JsonResponse(StoredFile.objects(id=ObjectId(file_id)).first())

@app.route("/api/files/<file_id>", methods=["PUT"])
@argument_doc('file_id', 'The id (string representation of the ObjectID) of the stored file.')
@accepts(StoredFile)
@returns(StoredFile)
def update_stored_file(file_id):
    """Update the properties of a stored file, you only have to include changed properties"""
    stored_file = StoredFile.objects(id=ObjectId(file_id)).first()