Skip to content

Commit

Permalink
fix #44 单元测试执行时导包错误
Browse files Browse the repository at this point in the history
  • Loading branch information
zy7y committed May 1, 2024
1 parent 4b1e93f commit 9442ae8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Workflow for Codecov example-python
on: [push, pull_request]
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: pip install -r requirements-test.txt
- name: Run tests and collect coverage
run: pytest --cov --cov-report xml:coverage.xml --cov-report term-missing
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
flags: smart-tests
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# dfs-generate
# dfs-generate [![codecov](https://codecov.io/gh/zy7y/dfs-generate/graph/badge.svg?token=ZTBA7CYTFC)](https://codecov.io/gh/zy7y/dfs-generate)
通过已有数据库表,生成FastAPI接口的工具项目,最终目的为FastAPI使用者,减少代码; 项目启发 Mybatis 逆向工程、[pdmaner](https://gitee.com/robergroup/pdmaner)

# 支持ORM
# 已支持从数据库表生成
- [x] SQLModel
- [x] Tortoise ORM
- [x] Vue
- [x] FastAPI 增加、删除、分页查询、详情查询、更新接口

# Generate Code
[FastAPI SQLModel MySQL](docs/sqlmodel)
Expand Down Expand Up @@ -56,6 +58,8 @@ source venv/bin/activate
pip install -r requirements.txt
```
### 运行
> 解决找不到模块问题
> mac / linux `export PYTHONPATH=./` windows `set PYTHONPATH=./`
```shell
python dfs_generate/server.py
```
Expand Down
4 changes: 2 additions & 2 deletions dfs_generate/conversion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from string import Template

from templates import (
from dfs_generate.templates import (
SQLMODEL_DAO,
TORTOISE_DAO,
RESPONSE_SCHEMA,
Expand All @@ -13,7 +13,7 @@
VUE_INDEX_VUE,
VUE_CRUD_TS,
)
from tools import to_pascal, tran, to_snake
from dfs_generate.tools import to_pascal, tran, to_snake


def _pydantic_field(column, imports):
Expand Down
4 changes: 2 additions & 2 deletions dfs_generate/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import isort
from yapf.yapflib.yapf_api import FormatCode

from conversion import SQLModelConversion, TortoiseConversion
from tools import MySQLConf, MySQLHelper
from dfs_generate.conversion import SQLModelConversion, TortoiseConversion
from dfs_generate.tools import MySQLConf, MySQLHelper

app = bottle.Bottle()

Expand Down
2 changes: 1 addition & 1 deletion dfs_generate/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pymysql

from types_map import TYPES
from dfs_generate.types_map import TYPES


def tran(t, mode) -> dict:
Expand Down
3 changes: 2 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-r requirements.txt
pytest
pytest==8.2.0
pytest-cov==5.0.0

0 comments on commit 9442ae8

Please sign in to comment.