-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: impl simple mock server
- Loading branch information
Showing
30 changed files
with
1,697 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from drf_yasg.inspectors import SwaggerAutoSchema | ||
|
||
|
||
class CustomSwaggerAutoSchema(SwaggerAutoSchema): | ||
def get_tags(self, operation_keys=None): | ||
if hasattr(self.view, 'swagger_tag'): | ||
return [self.view.swagger_tag] | ||
return super().get_tags(operation_keys) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
|
||
DEBUG = True | ||
|
||
# LOGGING["loggers"]["mock"]["level"] = "DEBUG" | ||
|
||
logger.remove() | ||
|
||
logger.add( | ||
|
@@ -22,7 +24,7 @@ | |
DATABASES = { | ||
"default": { | ||
"ENGINE": "django.db.backends.mysql", | ||
"NAME": "fast_dev", # 新建数据库 | ||
"NAME": "fast", # 新建数据库 | ||
# 'NAME': 'fast_mb4', # 新建数据库名 | ||
"HOST": "127.0.0.1", | ||
"USER": "root", # 数据库登录名 | ||
|
@@ -39,7 +41,7 @@ | |
BROKER_URL = "amqp://username:password@localhost:5672//" | ||
# 需要先在RabbitMQ上创建fast_dev这个vhost | ||
|
||
broker_url = 'amqp://admin:[email protected]:5672/fast_dev' | ||
broker_url = "amqp://admin:[email protected]:5672/fast_dev" | ||
|
||
|
||
BASE_REPORT_URL = "http://localhost:8000/api/fastrunner/reports" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class MockConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "mock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Generated by Django 4.1.13 on 2024-02-25 21:47 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="MockProject", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"create_time", | ||
models.DateTimeField(auto_now_add=True, verbose_name="创建时间"), | ||
), | ||
( | ||
"update_time", | ||
models.DateTimeField(auto_now=True, verbose_name="更新时间"), | ||
), | ||
( | ||
"creator", | ||
models.CharField(max_length=20, null=True, verbose_name="创建人"), | ||
), | ||
( | ||
"updater", | ||
models.CharField(max_length=20, null=True, verbose_name="更新人"), | ||
), | ||
("project_id", models.CharField(max_length=100, unique=True)), | ||
("project_name", models.CharField(max_length=100)), | ||
("project_desc", models.CharField(max_length=100)), | ||
("is_active", models.BooleanField(default=True)), | ||
], | ||
options={ | ||
"verbose_name": "mock项目表", | ||
"db_table": "mock_project_tab", | ||
"unique_together": {("project_id",)}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="MockAPI", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"create_time", | ||
models.DateTimeField(auto_now_add=True, verbose_name="创建时间"), | ||
), | ||
( | ||
"update_time", | ||
models.DateTimeField(auto_now=True, verbose_name="更新时间"), | ||
), | ||
( | ||
"creator", | ||
models.CharField(max_length=20, null=True, verbose_name="创建人"), | ||
), | ||
( | ||
"updater", | ||
models.CharField(max_length=20, null=True, verbose_name="更新人"), | ||
), | ||
("request_path", models.CharField(max_length=100)), | ||
( | ||
"request_method", | ||
models.CharField( | ||
choices=[ | ||
("GET", "GET"), | ||
("POST", "POST"), | ||
("PUT", "PUT"), | ||
("DELETE", "DELETE"), | ||
("PATCH", "PATCH"), | ||
], | ||
default="GET", | ||
max_length=10, | ||
), | ||
), | ||
("response_text", models.TextField()), | ||
("is_active", models.BooleanField(default=True)), | ||
( | ||
"project", | ||
models.ForeignKey( | ||
blank=True, | ||
db_constraint=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
to="mock.mockproject", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "mock接口表", | ||
"db_table": "mock_api_tab", | ||
"unique_together": {("project", "request_path", "request_method")}, | ||
}, | ||
), | ||
] |
29 changes: 29 additions & 0 deletions
29
mock/migrations/0002_alter_mockapi_options_alter_mockapi_project.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Generated by Django 4.1.13 on 2024-02-27 22:10 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("mock", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="mockapi", | ||
options={"ordering": ["-create_time"], "verbose_name": "mock接口表"}, | ||
), | ||
migrations.AlterField( | ||
model_name="mockapi", | ||
name="project", | ||
field=models.ForeignKey( | ||
blank=True, | ||
db_constraint=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
to="mock.mockproject", | ||
to_field="project_id", | ||
), | ||
), | ||
] |
46 changes: 46 additions & 0 deletions
46
mock/migrations/0003_mockapi_api_desc_mockapi_api_id_mockapi_api_name_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Generated by Django 4.1.13 on 2024-02-27 22:49 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("mock", "0002_alter_mockapi_options_alter_mockapi_project"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="mockapi", | ||
name="api_desc", | ||
field=models.CharField(blank=True, max_length=100, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="mockapi", | ||
name="api_id", | ||
field=models.CharField(default="4e9eb9a68bd8441d9c503f1347f156ff", max_length=32, unique=True), | ||
), | ||
migrations.AddField( | ||
model_name="mockapi", | ||
name="api_name", | ||
field=models.CharField(blank=True, max_length=100, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="mockapi", | ||
name="followers", | ||
field=models.JSONField(blank=True, default=list, null=True, verbose_name="关注者"), | ||
), | ||
migrations.AlterField( | ||
model_name="mockapi", | ||
name="project", | ||
field=models.ForeignKey( | ||
blank=True, | ||
db_constraint=False, | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
related_name="mock_apis", | ||
to="mock.mockproject", | ||
to_field="project_id", | ||
), | ||
), | ||
] |
Oops, something went wrong.