1234567891011121314151617181920212223242526272829303132333435363738 |
- """testing subjects utils"""
- from sqlalchemy.orm import Session
- from db.repository import trains as db_rep_train
- from schemas.trains import TrainCreate
- from utils.utils import fake
- from utils.utils import get_random_position
- def generate_fake_train_data():
- return {
- "position": "左手",
- "rank": fake.train_rank(),
- "trial_num": fake.random_digit_not_null(),
- "start_time": "2022-11-03 00:00",
- "end_time": "2022-11-04 00:00"
- }
- def create_test_train2db(db: Session,
- subject,
- position=None,
- rank=fake.train_rank(),
- trial_num=fake.random_digit_not_null(),
- start_time="2022-11-03 00:00",
- end_time="2022-11-04 00:00",
- device_parm=None) -> TrainCreate:
- if position is None:
- position = get_random_position(subject)
- train = TrainCreate(position=position,
- rank=rank,
- trial_num=trial_num,
- start_time=start_time,
- end_time=end_time,
- device_parm=device_parm,
- owner_id=subject.id)
- train = db_rep_train.create_train(train, db)
- return train
|