Example #1
0
def index_api() -> flask.wrappers.Response:
    '''gives information for suites view in json format'''
    suites = []  # type: list
    for suite in SuiteDao.list_suites():
        suites += [
            suite +
            (SuiteDao.get_most_recent_run_state(suite[1]) or (('never', ), ))[0] +
            (SuiteDao.get_test_count(suite[1]) or ((0, ), ))[0]
        ]
    headers = ['name', 'id', 'description', 'browser', 'width', 'height', 'last_ran', 'test_count']
    return jsonify([dict(zip(headers, i)) for i in suites])
Example #2
0
def post_add_suite():
    '''
        adds a new suite to the database
    '''
    if request.form.get('suitename'):
        name = request.form.get('suitename')
        browser = request.form.get('browser')
        description = request.form.get('description')
        width = request.form.get('width')
        height = request.form.get('height')
        SuiteDao.add_suite(name, description, browser, width, height, False, 0)
        return redirect(url_for('index'))
Example #3
0
def edit_suite(suite_id: int) -> str:
    '''
        form for editing a suite
    '''
    browser, width, height = SuiteDao.get_settings_for_suite(suite_id)
    suite_name, description = SuiteDao.get_suite(suite_id)
    scheduled, interval = SuiteDao.get_schedule_config(suite_id)
    return render_template(
        'edit/suite.html',
        suite_name=suite_name,
        suite_id=suite_id,
        description=description,
        browser=browser,
        width=width,
        height=height,
        scheduled=scheduled,
        interval=interval
        )
Example #4
0
def post_edit_suite(suite_id: int):
    '''
        edit a suite
    '''
    suite_name = request.form.get('suitename')
    description = request.form.get('description')
    browser = request.form.get('browser')
    width = request.form.get('width')
    height = request.form.get('height')
    if SuiteDao.get_schedule_config(suite_id)[1]:
        print("config exists")
    scheduled = request.form.get('scheduled')
    interval = request.form.get('interval')
    if is_int(interval):
        if int(interval) > 0:
            SuiteDao.update_schedule_config(
                suite_id, bool(scheduled), int(interval))
    SuiteDao.update_suite_settings(suite_id, browser, width, height)
    SuiteDao.update_suite(suite_id, suite_name, description)
    return redirect(url_for('view_suite', suite_id=suite_id))
Example #5
0
import time
import requests
from multiprocessing import Process
from Daos import SuiteDao
from Daos import TestDao

while True:
    #     for scheduled_id, suite_id, test_id in TestDao.get_tests_scheduled_later_than_now():
    #         print("posting to /suites/{}/tests/{}/run".format(suite_id, test_id))
    #         print("updating {}".format(scheduled_id))
    #         TestDao.schedule_next_test(scheduled_id)
    for scheduled_id, suite_id in SuiteDao.get_suites_scheduled_later_than_now(
    ):
        print("sending request to http://localhost:8080/suites/{}/run".format(
            suite_id))
        requests.get(
            url="http://localhost:8080/suites/{}/run".format(suite_id))
        print("updating runtime")
        SuiteDao.schedule_next_suite(scheduled_id)
    time.sleep(60)
Example #6
0
def suite_copy_api(suite_id: int) -> flask.wrappers.Response:
    data = {
        "suites": [{"name": i[0], "id": i[1]} for i in SuiteDao.list_suites()],
        "tests": [{"name": i[0], "id": i[1]} for i in TestDao.get_full_test_info(suite_id)]
    }
    return jsonify(data)
Example #7
0
def delete_suite(suite_id: int) -> str:
    '''delete an entire suite'''
    SuiteDao.delete_suite(suite_id)
    return "OK"
Example #8
0
def copy_suite():
    '''copy an entire suite'''
    suite = int(request.form.get('suite'))
    SuiteDao.copy_suite(suite)
    return redirect(url_for('index'))
Example #9
0
def run_test(suite_id: int, test_id: int):
    '''run a test'''
    browser, width, height = SuiteDao.get_settings_for_suite(suite_id)
    q.enqueue(navigator.run_test, test_id, (width, height), browser)
    return redirect(url_for('view_test', suite_id=suite_id, test_id=test_id))