Commit 0b583ff3 authored by unknown's avatar unknown

set api version

parent 4fdd29b5
Pipeline #3279 passed with stage
in 28 seconds
......@@ -8,10 +8,14 @@ HTTP_PROTOCOL=http
# PRODCUTION URI
FONTEND_URL=http://localhost:8080/
VUE_APP_BACKEND_API_URL=http://localhost:8080/api
VUE_APP_BACKEND_API_URL=http://localhost:8080/api/v1
# DEVELOPMENT URI
VUE_APP_BACKEND_API_URL_DEV=http://localhost:3001/api
VUE_APP_BACKEND_API_URL_DEV=http://localhost:3001/api/v1
# TESTS URI
VUE_APP_BACKEND_API_URL_TESTS=http://frontend:80/api
API_TESTS_BACKEND=http://backend:3001/api
\ No newline at end of file
VUE_APP_BACKEND_API_URL_TESTS=http://frontend:80/api/v1
API_TESTS_BACKEND=http://backend:3001/api/v1
# REST API VERSION
VERSION=v1
\ No newline at end of file
FROM python:3.8 as dev-stage
WORKDIR /backend
COPY . /backend
ARG VERSION
ENV VERSION ${VERSION}
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
\ No newline at end of file
......@@ -11,8 +11,11 @@ USER uwsgi
ARG PORT
ARG PROTOCOL
ARG VERSION
ENV PORT ${PORT}
ENV PROTOCOL ${PROTOCOL}
ENV VERSION ${VERSION}
CMD sh prestart.sh && uwsgi conf/uwsgi.ini
\ No newline at end of file
......@@ -86,8 +86,8 @@ class Core:
required_methods = ['parse', 'register']
try:
for _, name, _ in iter_modules([environ['PARSER_FOLDER']]):
import_module('.' + name, environ['PACKAGE'])
for _, name, _ in iter_modules(['parse']):
import_module('.' + name, 'parse')
except TypeError as te:
Logger.error.log(message='Problem occurred while importing classes: {}'.format(te), f_exit=True)
print(str(te))
......
"""
@author Jakub Dolejsi
"""
import os
from resources.v1.endpoints.File import File
from resources.v1.endpoints.Files import Files
......@@ -15,6 +16,7 @@ class RepViewInterface:
"""
kwargs = {}
api = None
version = None
@classmethod
def setup(cls, wrapped_object, api):
......@@ -27,15 +29,35 @@ class RepViewInterface:
'core': wrapped_object,
}
cls.api = api
cls.version = os.environ['VERSION']
@classmethod
def initialize_routes(cls):
"""
Initialize all resources
"""
cls.api.add_resource(File, '/api/file/<string:id>/<string:folder>', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Files, '/api/files/<string:id>/<string:folder>', '/api/files/<string:id>', '/api/files',
'/api/files/', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Tools, '/api/tools', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Report, '/api/report/<string:id>/<string:folder>', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Version, '/api/version', endpoint='version', resource_class_kwargs=cls.kwargs)
base_route = '/api/' + cls.version
cls.__validate_route(base_route)
cls.api.add_resource(File, base_route + '/file/<string:id>/<string:folder>', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Files, base_route + '/files/<string:id>/<string:folder>', base_route + '/files/<string:id>', base_route + '/files',
base_route + '/files/', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Tools, base_route + '/tools', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Report, base_route + '/report/<string:id>/<string:folder>', resource_class_kwargs=cls.kwargs)
cls.api.add_resource(Version, base_route + '/version', endpoint='version', resource_class_kwargs=cls.kwargs)
@classmethod
def __validate_route(cls, base)-> None:
"""
Base api route validator
@param base: base api url
@raise Exception if url is not valid
"""
import re
validate_pattern = 'v(\d)'
is_valid = re.search(validate_pattern, base)
if not is_valid:
raise Exception('Route :', base , ' is not valid')
......@@ -12,10 +12,7 @@ services:
- data-volume:/backend/uploaded_files
- ./backend:/backend
environment:
- PARSER_FOLDER=parse
- LOG_DIR=log_dir
- VERSION=1.0.1
- PACKAGE=parse
- VERSION=${VERSION}
- PORT=${BACKEND_PORT}
- PROTOCOL=${HTTP_PROTOCOL}
frontend:
......
......@@ -13,10 +13,7 @@ services:
- data-volume:/backend/uploaded_files
- ./backend:/backend
environment:
- PARSER_FOLDER=parse
- LOG_DIR=log_dir
- VERSION=1.0.1
- PACKAGE=parse
- VERSION=${VERSION}
- PORT=${BACKEND_PORT}
- PROTOCOL=${HTTP_PROTOCOL}
privileged: true
......
......@@ -65,10 +65,7 @@ services:
- ./backend:/backend
- data-volume:/backend/uploaded_files
environment:
- PARSER_FOLDER=parse
- LOG_DIR=log_dir
- VERSION=1.0.1
- PACKAGE=parse
- VERSION=${VERSION}
- PORT=${BACKEND_PORT}
- PROTOCOL=${HTTP_PROTOCOL}
privileged: true
......
......@@ -5,7 +5,7 @@ import requests
url = os.environ['API_URI'] + '/version' # change in docker
res = None
version = '1.0.1'
version = 'v1'
def test_availability_check():
......
......@@ -49,8 +49,6 @@ def step_impl(context):
copy_notify = context.driver.find_element_by_xpath('/html/body/div[2]/div[6]/div/div/div/div').text
assert copy_notify
@step("reported line is shown")
def step_impl(context):
......
......@@ -92,7 +92,6 @@ def step_impl(context):
def step_impl(context):
message = context.driver.find_element_by_xpath('/html/body/div[2]/div[6]/div/div/div/div').text
assert message
@when("user clicks on Load button")
......@@ -116,15 +115,12 @@ def step_impl(context):
def step_impl(context):
message = context.driver.find_element_by_xpath('/html/body/div[2]/div[6]/div/div/div/div').text
assert message
@then("folders are successfully deleted")
def step_impl(context):
message = context.driver.find_element_by_xpath('/html/body/div[2]/div[6]/div/div/div/div').text
assert message
@step("update report")
def step_impl(context):
......@@ -142,5 +138,3 @@ def step_impl(context):
@then("report is successfully updated")
def step_impl(context):
message = context.driver.find_element_by_xpath('/html/body/div[2]/div[6]/div/div/div/div').text
assert message
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment