Skip to content

Commit

Permalink
make api compatible for both runtime and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Feb 4, 2024
1 parent d080b24 commit 2e17047
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 7 additions & 1 deletion api/src/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# 3rd parth dependencies
from flask import Flask
from modules.core.routes import blueprint

try:
# unit tests
from api.src.modules.core.routes import blueprint
except:
# runtime
from modules.core.routes import blueprint


def create_app():
Expand Down
9 changes: 8 additions & 1 deletion api/src/modules/core/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from flask import Blueprint, request
from modules.core import service

try:
# unit tests
from api.src.modules.core import service
except:
# runtime
from modules.core import service

from deepface.commons.logger import Logger

logger = Logger(module="api/src/routes.py")
Expand Down
7 changes: 1 addition & 6 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import sys
import unittest
from deepface.commons import constant
from deepface.commons.logger import Logger

# api is not available under deepface import
sys.path.insert(1, f"{constant.ROOT_DIR}/api/src")
# pylint: disable=wrong-import-order, wrong-import-position
from app import create_app
from api.src.app import create_app

logger = Logger("tests/test_api.py")

Expand Down

0 comments on commit 2e17047

Please sign in to comment.