Пример #1
0
def test_get_project_fail(temp_app, temp_db):
    '''Tests various failure cases when getting a project'''

    # Tests trying to get nonexistent project
    login_res = login_mackland(temp_app)
    auth_token = login_res['accessToken']
    res = get_project(0, auth_token, temp_app)
    res_data = json.loads(res.data)
    assert res.status_code == 400
    assert res_data['error'] == 'Project does not exist'

    # Tests trying to get a project created by a different user
    res = get_project(1, auth_token, temp_app)
    res_data = json.loads(res.data)
    assert res.status_code == 403
    assert res_data['error'] == 'Forbidden: project belongs to another user'

    # Tests trying to get a project with no auth header
    res = temp_app.get('/project/1')
    res_data = json.loads(res.data)
    assert res.status_code == 401
    assert res_data['error'] == 'No authentication provided'

    # Tests trying to get a project with no auth token
    res = temp_app.get('/project/1', headers=dict(Authorization='Bearer '))
    res_data = json.loads(res.data)
    assert res.status_code == 401
    assert res_data['error'] == 'No authentication provided'

    # Tests trying to get a project with an expired token
    token = generate_expired_token('access',
                                   temp_app.application.config['SECRET_KEY'])
    res = get_project(1, token, temp_app)
    res_data = json.loads(res.data)
    assert res.status_code == 401
    assert res_data['error'] == 'Invalid token'

    # Tests trying to get a project with a token signed with the wrong key
    token = generate_invalid_token('access')
    res = get_project(1, token, temp_app)
    res_data = json.loads(res.data)
    assert res.status_code == 401
    assert res_data['error'] == 'Invalid token'

    # Tests trying to use a refresh token to access projects
    token = encode_auth_token('refresh', 1, datetime.timedelta(days=3),
                              temp_app.application.config['SECRET_KEY'])
    res = get_project(1, token.decode(), temp_app)
    res_data = json.loads(res.data)
    assert res.status_code == 401
    assert res_data['error'] == 'Invalid token type'
Пример #2
0
def web_tasks(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)
        result['user'] = user

        project_id = int(request.GET['project_id'])

        completed = False
        try:
            completed = int(request.GET['completed']);
        except:
            pass

        result['completed'] = completed

        result['tasks'] = get_tasks(project_id, completed)

        result['project'] = get_project(user.id, project_id)

    except:
        pass

    return result 
Пример #3
0
def web_manage_project(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)

        project_id = request.GET['project_id']

        result['user'] = user

        result['project'] = get_project(user.id, project_id)
        
        result['tasks'] = get_tasks(project_id, completed=False)

        result['tickets'] = get_tickets(project_id)

        result['lists'] = [] #get_lists(project_id)

        #result['projects'] = get_projects(user);

    except:
        pass

    return result
Пример #4
0
def web_owner_tickets(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)
        result['user'] = user

        project_id = int(request.GET['project_id'])

        result['tickets'] = get_tickets(
            project_id = project_id,
            closed = False,
            unassigned = False,
            user_id = user.id,
            opened = True,
        )

        result['project'] = get_project(user.id, project_id)

    except:
        pass

    return result 
Пример #5
0
def web_ticket(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)
        result['user'] = user

        ticket_id = request.GET['ticket_id']
        #project_id = request.GET['project_id']

        ticket = get_ticket(
            user_id = user.id, 
            ticket_id = ticket_id,
        )
        
        result['ticket'] = ticket

        result['comments'] = get_ticket_comments(user.id, ticket['id'])

        result['tickets'] = get_tickets(ticket['project_id'])

        result['assigned_users'] = get_users_assigned_to_project(user.id, ticket['project_id'])

        result['project'] = get_project(user.id, ticket['project_id'])

    except:
        pass

    return result
Пример #6
0
def web_projectsettings(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)
        result['user'] = user

        project_id = request.GET['project_id']
            
        result['project'] = get_project(user.id, project_id)

        result['organization_users'] = get_organization_users(user.organization_id);
        
        result['assigned_users'] = get_users_assigned_to_project(user.id, project_id)

        result['tasks'] = get_tasks(project_id)

        result['tickets'] = get_tickets(project_id)


    except:
        pass

    return result
Пример #7
0
def web_task(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)
        result['user'] = user

        task_id = request.GET['task_id']
        #project_id = request.GET['project_id']

        task = get_task(task_id)
        result['task'] = task

        result['comments'] = get_task_comments(task['id'])

        result['tasks'] = get_tasks(task['project_id'], completed=False)

        result['project'] = get_project(user.id, task['project_id'])


    except:
        pass

    return result
Пример #8
0
def test_get_project(temp_app, temp_db):
    '''Tests getting a specific project (with tracks)'''
    login_res = login_hello(temp_app)
    auth_token = login_res['accessToken']
    res = get_project(1, auth_token, temp_app)
    res_data = json.loads(res.data)
    assert res.status_code == 200
    assert isinstance(res_data['project'], dict)
    assert 'id' in res_data
    assert 'name' not in res_data
Пример #9
0
def web_new_list(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)
        result['user'] = user

        project_id = request.GET['project_id']

        result['project'] = get_project(user.id, project_id)

        result['lists'] = get_lists(project_id)

    except:
        pass

    return result
Пример #10
0
def web_new_task(request):

    result = {'user': None}
    #if True:
    try:

        user, token = check_auth(request)
        result['user'] = user

        project_id = request.GET['project_id']

        result['project'] = get_project(user.id, project_id)

        result['assigned_users'] = get_users_assigned_to_project(user.id, project_id)

        result['tasks'] = get_tasks(project_id)

    except:
        pass

    return result
Пример #11
0
def web_new_ticket(request):

    result = {'user': None}
    if True:
    #try:
    
        user, token = check_auth(request)
        result['user'] = user

        project_id = request.GET['project_id']

        result['project'] = get_project(user.id, project_id)
   
        result['assigned_users'] = get_users_assigned_to_project(user.id, project_id)
   
        result['tickets'] = get_tickets(project_id)

        result['ticket_priorities'] = get_ticket_priorities(project_id)
 
    #except:
    #    pass

    return result
Пример #12
0
def intent():
    global project
    rasa_cfg = config['rasa_nlu']

    if request.method == 'POST':
        command = request.data.decode('utf-8')
        logging.debug('Sending command: %s' % command)

        if project is None:
            project = get_project(rasa_cfg['project_name'],
                                  rasa_cfg['project_dir'])

        intents = project.parse(command)
        return json.dumps(intents)

    # Re-load training phrases
    example_files = config['training']['example_files']
    intent_examples = load_training_phrases(example_files)

    return render_template('intent-recognition.html',
                           current_page='intent-recognition',
                           intent_examples=intent_examples,
                           example_files=example_files,
                           rasa_cfg=rasa_cfg)
Пример #13
0
unittest for visitors.diadefs and extensions.diadefslib modules
"""

import unittest

from logilab.astng.inspector import Linker
from logilab.common.testlib import TestCase, unittest_main

from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
from pylint.pyreverse.diagrams import set_counter
from pylint.pyreverse.writer import DotWriter

from pylint.pyreverse.utils import get_visibility
from utils import FileTC, build_file_case, get_project, Config

project = get_project('data')
linker = Linker(project)
set_counter(0)

config = Config()

handler = DiadefsHandler(config)
dd = DefaultDiadefGenerator(linker, handler).visit(project)
for diagram in dd:
    diagram.extract_relationships()

class DotWriterTC(FileTC):

    generated_files = ('packages_No_Name.dot', 'classes_No_Name.dot',)
    def setUp(self):
        FileTC.setUp(self)
Пример #14
0
"""
unittest for visitors.diadefs and extensions.diadefslib modules
"""

from os.path import abspath, dirname, join
from logilab.astng.inspector import Linker
from logilab.common.testlib import TestCase, unittest_main

from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
from pylint.pyreverse.diagrams import set_counter
from pylint.pyreverse.writer import DotWriter

from pylint.pyreverse.utils import get_visibility
from utils import FileTC, build_file_case, get_project, Config

project = get_project(join(dirname(abspath(__file__)), 'data'))
linker = Linker(project)
set_counter(0)

config = Config()

handler = DiadefsHandler(config)
dd = DefaultDiadefGenerator(linker, handler).visit(project)
for diagram in dd:
    diagram.extract_relationships()


class DotWriterTC(FileTC):

    generated_files = (
        'packages_No_Name.dot',
Пример #15
0
 def fromPHID(phid):
     if phid in phid_cache:
         return phid_cache[phid]
     else:
         return Project(utils.get_project(phid))
unittest for visitors.diadefs and extensions.diadefslib modules
"""

import unittest

from logilab.astng.inspector import Linker
from logilab.common.testlib import TestCase, unittest_main

from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
from pylint.pyreverse.diagrams import set_counter
from pylint.pyreverse.writer import DotWriter

from pylint.pyreverse.utils import get_visibility
from utils import FileTC, build_file_case, get_project, Config

project = get_project('data')
linker = Linker(project)
set_counter(0)

config = Config()

handler = DiadefsHandler(config)
dd = DefaultDiadefGenerator(linker, handler).visit(project)
for diagram in dd:
    diagram.extract_relationships()


class DotWriterTC(FileTC):

    generated_files = (
        'packages_No_Name.dot',
"""
unittest for visitors.diadefs and extensions.diadefslib modules
"""

from os.path import abspath, dirname, join
from logilab.astng.inspector import Linker
from logilab.common.testlib import TestCase, unittest_main

from pylint.pyreverse.diadefslib import DefaultDiadefGenerator, DiadefsHandler
from pylint.pyreverse.diagrams import set_counter
from pylint.pyreverse.writer import DotWriter

from pylint.pyreverse.utils import get_visibility
from utils import FileTC, build_file_case, get_project, Config

project = get_project(join(dirname(abspath(__file__)), 'data'))
linker = Linker(project)
set_counter(0)

config = Config()

handler = DiadefsHandler(config)
dd = DefaultDiadefGenerator(linker, handler).visit(project)
for diagram in dd:
    diagram.extract_relationships()

class DotWriterTC(FileTC):

    generated_files = ('packages_No_Name.dot', 'classes_No_Name.dot',)
    def setUp(self):
        FileTC.setUp(self)