Skip to content

Commit

Permalink
[ADD] Get cases by the current user identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
c8y3 committed Mar 18, 2024
1 parent e38c4e7 commit f3f81d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
10 changes: 10 additions & 0 deletions source/app/blueprints/graphql/graphql_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
from flask import request
from flask_wtf import FlaskForm
from flask import Blueprint
from flask_login import current_user

from graphql_server.flask import GraphQLView
from graphene import ObjectType, String, Schema, List
from graphene_sqlalchemy import SQLAlchemyObjectType

from app.models.cases import Cases
from app.util import is_user_authenticated
from app.util import response_error
from app.datamgmt.manage.manage_cases_db import get_filtered_cases


class CaseObject(SQLAlchemyObjectType):
Expand All @@ -43,6 +46,13 @@ class Query(ObjectType):
# starting with the conversion of '/manage/cases/list'
cases = List(lambda: CaseObject, description='author documentation')

def resolve_cases(self, info):
# TODO missing permissions
# TODO add all parameters to filter
# TODO parameter current_user_id should be mandatory on get_filtered_cases
filtered_cases = get_filtered_cases(current_user_id=current_user.id)
return filtered_cases.items

def resolve_hello(root, info, first_name):
return f'Hello {first_name}!'

Expand Down
8 changes: 5 additions & 3 deletions tests/docker_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@

import subprocess

_DOCKER_COMPOSE = ['docker', 'compose']


class DockerCompose:

def __init__(self, docker_compose_path):
self._docker_compose_path = docker_compose_path

def start(self):
subprocess.check_call(['docker', 'compose', 'up', '--detach'], cwd=self._docker_compose_path)
subprocess.check_call(_DOCKER_COMPOSE + ['up', '--detach'], cwd=self._docker_compose_path)

def extract_all_logs(self):
return subprocess.check_output(['docker', 'compose', 'logs', '--no-color'], cwd=self._docker_compose_path, universal_newlines=True)
return subprocess.check_output(_DOCKER_COMPOSE + ['logs', '--no-color'], cwd=self._docker_compose_path, universal_newlines=True)

def stop(self):
subprocess.check_call(['docker', 'compose', 'down', '--volumes'], cwd=self._docker_compose_path)
subprocess.check_call(_DOCKER_COMPOSE + ['down', '--volumes'], cwd=self._docker_compose_path)
5 changes: 4 additions & 1 deletion tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ def test_graphql_cases_should_contain_the_initial_case(self):
'query': '{ cases { name } }'
}
body = self._subject.execute_graphql_query(payload)
# TODO should check the list contains an element with name "#1 - Initial Demo"
case_names = []
for case in body['data']['cases']:
case_names.append(case['name'])
self.assertIn('#1 - Initial Demo', case_names)

0 comments on commit f3f81d0

Please sign in to comment.