Skip to content

Commit

Permalink
feat: init pytest workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai committed Aug 21, 2024
1 parent 15750bc commit 53781a5
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 37 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ builtins = ["_"]

[pytest]
testpaths = ["tests"]
rootdir = "server"
pythonpath = "server"
pythonpath = "."
consider_namespace_packages = "True"
python_files = "test_*.py"
cov="com"
Expand Down
6 changes: 3 additions & 3 deletions server/agent/bot_builder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import AsyncIterator, Optional
from petercat_utils.data_class import ChatData

from ..agent.base import AgentBuilder
from ..prompts.bot_builder import generate_prompt_by_user_id
from ..tools import bot_builder
from agent.base import AgentBuilder
from prompts.bot_builder import generate_prompt_by_user_id
from tools import bot_builder


TOOL_MAPPING = {
Expand Down
6 changes: 3 additions & 3 deletions server/agent/qa_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from petercat_utils import get_client
from petercat_utils.data_class import ChatData

from ..agent.base import AgentBuilder
from ..prompts.bot_template import generate_prompt_by_repo_name
from ..tools import issue, sourcecode, knowledge, git_info
from agent.base import AgentBuilder
from prompts.bot_template import generate_prompt_by_repo_name
from tools import issue, sourcecode, knowledge, git_info


def get_tools(bot_id: str, token: Optional[str]):
Expand Down
2 changes: 1 addition & 1 deletion server/bot/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from petercat_utils.data_class import RAGGitDocConfig
from petercat_utils import git_doc_task

from ..prompts.bot_template import generate_prompt_by_repo_name
from prompts.bot_template import generate_prompt_by_repo_name

g = Github()

Expand Down
4 changes: 2 additions & 2 deletions server/dao/authorizationDAO.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from petercat_utils.db.client.supabase import get_client

from ..dao.BaseDAO import BaseDAO
from ..models.authorization import Authorization
from dao.BaseDAO import BaseDAO
from models.authorization import Authorization

class AuthorizationDAO(BaseDAO):
client: Client
Expand Down
4 changes: 2 additions & 2 deletions server/dao/repositoryConfigDAO.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from supabase.client import Client
from petercat_utils.db.client.supabase import get_client

from ..dao.BaseDAO import BaseDAO
from ..models.repository import RepositoryConfig
from dao.BaseDAO import BaseDAO
from models.repository import RepositoryConfig
class RepositoryConfigDAO(BaseDAO):
client: Client

Expand Down
2 changes: 1 addition & 1 deletion server/event_handler/discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from petercat_utils.data_class import ChatData, Message, TextContentBlock

from ..agent.qa_chat import agent_chat
from agent.qa_chat import agent_chat


class DiscussionEventHandler:
Expand Down
2 changes: 1 addition & 1 deletion server/event_handler/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from petercat_utils.data_class import ChatData, Message, TextContentBlock

from ..agent.qa_chat import agent_chat
from agent.qa_chat import agent_chat


class IssueEventHandler:
Expand Down
2 changes: 1 addition & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


# Import fastapi routers
from .routers import bot, health_checker, github, rag, auth, chat, task
from routers import bot, health_checker, github, rag, auth, chat, task

AUTH0_DOMAIN = get_env_variable("AUTH0_DOMAIN")
API_AUDIENCE = get_env_variable("API_IDENTIFIER")
Expand Down
2 changes: 1 addition & 1 deletion server/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import httpx
from petercat_utils import get_client, get_env_variable

from ..auth.get_user_info import generateAnonymousUser, getAnonymousUserInfoByToken, getUserInfoByToken
from auth.get_user_info import generateAnonymousUser, getAnonymousUserInfoByToken, getUserInfoByToken

AUTH0_DOMAIN = get_env_variable("AUTH0_DOMAIN")

Expand Down
6 changes: 3 additions & 3 deletions server/routers/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from petercat_utils import get_client
from typing import Annotated, Optional

from ..auth.get_user_info import get_user_id
from ..bot.builder import bot_builder, bot_info_generator
from ..type_class.bot import BotUpdateRequest, BotCreateRequest
from auth.get_user_info import get_user_id
from bot.builder import bot_builder, bot_info_generator
from type_class.bot import BotUpdateRequest, BotCreateRequest

router = APIRouter(
prefix="/api/bot",
Expand Down
6 changes: 3 additions & 3 deletions server/routers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from fastapi.responses import StreamingResponse
from petercat_utils.data_class import ChatData

from ..agent import qa_chat, bot_builder
from ..verify.rate_limit import verify_rate_limit
from ..auth.get_user_info import get_user_access_token, get_user_id
from agent import qa_chat, bot_builder
from verify.rate_limit import verify_rate_limit
from auth.get_user_info import get_user_access_token, get_user_id


router = APIRouter(
Expand Down
12 changes: 6 additions & 6 deletions server/routers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from petercat_utils import get_env_variable
from jwt import JWT, jwk_from_pem

from ..auth.get_user_info import get_user_access_token
from ..dao.authorizationDAO import AuthorizationDAO
from ..dao.repositoryConfigDAO import RepositoryConfigDAO
from ..models.repository import RepositoryConfig
from ..models.authorization import Authorization
from ..utils.github import get_handler, get_private_key
from auth.get_user_info import get_user_access_token
from dao.authorizationDAO import AuthorizationDAO
from dao.repositoryConfigDAO import RepositoryConfigDAO
from models.repository import RepositoryConfig
from models.authorization import Authorization
from utils.github import get_handler, get_private_key

APP_ID = get_env_variable("X_GITHUB_APP_ID")
WEB_URL = get_env_variable("WEB_URL")
Expand Down
2 changes: 1 addition & 1 deletion server/routers/rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
git_issue_task,
)

from ..verify.rate_limit import verify_rate_limit
from verify.rate_limit import verify_rate_limit


router = APIRouter(
Expand Down
2 changes: 1 addition & 1 deletion server/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi.testclient import TestClient
from ..main import app
from main import app

client = TestClient(app)

Expand Down
2 changes: 1 addition & 1 deletion server/tools/bot_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from github import Github
from petercat_utils import get_client

from ..bot.builder import bot_builder
from bot.builder import bot_builder

g = Github()

Expand Down
2 changes: 1 addition & 1 deletion server/tools/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from github import Auth, Github
from langchain.tools import tool

from ..tools.helper import need_github_login
from tools.helper import need_github_login

DEFAULT_REPO_NAME = "ant-design/ant-design"

Expand Down
6 changes: 3 additions & 3 deletions server/utils/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from petercat_utils import get_env_variable
from github import Auth

from ..event_handler.pull_request import PullRequestEventHandler
from ..event_handler.discussion import DiscussionEventHandler
from ..event_handler.issue import IssueEventHandler
from event_handler.pull_request import PullRequestEventHandler
from event_handler.discussion import DiscussionEventHandler
from event_handler.issue import IssueEventHandler

APP_ID = get_env_variable("X_GITHUB_APP_ID")

Expand Down
2 changes: 1 addition & 1 deletion server/verify/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from petercat_utils import get_client, get_env_variable

from ..auth.get_user_info import getUserInfoByToken
from auth.get_user_info import getUserInfoByToken

RATE_LIMIT_ENABLED = get_env_variable("RATE_LIMIT_ENABLED", "False") == 'True'
RATE_LIMIT_REQUESTS = get_env_variable("RATE_LIMIT_REQUESTS") or 100
Expand Down

0 comments on commit 53781a5

Please sign in to comment.