-
Notifications
You must be signed in to change notification settings - Fork 0
测试 pullrequest #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cry625
wants to merge
1
commit into
main
Choose a base branch
from
dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,52 @@ | ||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. | ||
| from myapp.models import Event | ||
| import random | ||
| from datetime import timedelta, datetime | ||
| # 示例数据生成函数 | ||
| def generate_events(): | ||
| categories = ['career', 'hobby', 'life'] | ||
| quadrants = ['IU', 'INU', 'NU', 'NNU'] | ||
| titles = [ | ||
| "项目进度会议111", "健身计划", "家庭聚会", "阅读新书", | ||
| "职业发展培训", "周末旅行", "学习新技能", "健康检查", | ||
| "工作报告提交", "志愿者活动", "参加研讨会", "朋友聚餐", | ||
| "写作计划", "整理房间", "社交活动", "参加课程", | ||
| "制定预算", "参加音乐会", "看电影", "做饭", | ||
| "参加运动会", "更新简历", "学习外语", "家庭游戏夜", | ||
| "参加工作坊", "处理账单", "计划假期", "参加聚会", | ||
| "清理邮箱", "参加网络研讨会", "制定职业目标", "学习编程", | ||
| "参加摄影展", "做志愿者", "进行职业咨询", "参加社区活动", | ||
| "制定饮食计划", "参加技能培训", "进行心理咨询", "参加读书会", | ||
| "学习理财", "参加马拉松", "参加展览", "进行团队建设", | ||
| "参加厨艺班", "进行家庭计划", "参加创意工作坊", "进行自我反思", | ||
| "参加文化活动", "进行职业规划" | ||
| ] | ||
|
|
||
| events = [] | ||
| for _ in range(50): | ||
| category = random.choice(categories) | ||
| quadrant = random.choice(quadrants) | ||
| title = random.choice(titles) | ||
| description = f"{title} 的详细描述。" | ||
| deadline = datetime.now() + timedelta(days=random.randint(1, 30)) # 随机截止日期 | ||
|
|
||
| event = Event( | ||
| quadrant=quadrant, | ||
| category=category, | ||
| title=title, | ||
| description=description, | ||
| deadline=deadline.date(), | ||
| created_at=datetime.now(), | ||
| updated_at=datetime.now() | ||
| ) | ||
| events.append(event) | ||
|
|
||
| return events | ||
|
|
||
| # 插入数据到数据库 | ||
| def insert_events(): | ||
| events = generate_events() | ||
| Event.objects.bulk_create(events) # 批量插入 | ||
| print(f"成功插入 {len(events)} 条事件数据。") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok