コード例 #1
0
def setup_periodic_tasks(sender, **kwargs):
    # 每十分钟执行test('hello')
    for mission_dict in get_valid_mission_missionary():
        mission = mission_dict['mission']
        missionary = mission_dict['missionary']
        run_time = RUN_TIME_SCHEDULE[missionary.run_time]
        sender.add_periodic_task(run_time, run_mission.s(mission.id), name='mission-{}'.format(mission.id))
    log.info('after add all missionary, the mission id to entry: {}')
コード例 #2
0
def test_auto_create_missionary():
    """ 测试mission.interface.get_valid_mission_missionary() 是否可以根据mission创建不存在的missionary"""
    not_valid_mission = create_not_valid_mission()
    valid_mission = create_valid_mission()
    save_many_models(not_valid_mission, valid_mission)
    result = get_valid_mission_missionary()
    has_missionary = False
    wrong = False
    for d in result:
        if d['missionary'].mission_id == valid_mission.id:
            has_missionary = True
        if d['missionary'].mission_id == not_valid_mission.id:
            wrong = True

    assert has_missionary is True
    assert wrong is False
コード例 #3
0
ファイル: test.py プロジェクト: chen-zhuohan/HuobiAutoTrade
    def test_get_valid_mission_missionary(self, ):
        """ 测试mission.interface.get_valid_mission_missionary() 是否可以正确筛选可用的mission以及missionary"""
        not_valid_mission = self.create_not_valid_mission()
        valid_mission = self.create_valid_mission()

        is_end_missionary_valid = self.create_is_end_missionary(
            valid_mission.id)
        is_end_missionary_not_valid = self.create_is_end_missionary(
            not_valid_mission.id)
        not_end_missionary_valid = self.create_not_end_missionary(
            valid_mission.id)
        not_end_missionary_not_valid = self.create_not_end_missionary(
            not_valid_mission.id)

        result = get_valid_mission_missionary()
        for d in result:
            assert d['mission'].is_valid is True
            assert d['mission'].id == valid_mission.id
            assert d['missionary'].is_end is False
            assert d['missionary'].id == not_end_missionary_valid.id
コード例 #4
0
def test_get_valid_mission_missionary():
    """ 测试mission.interface.get_valid_mission_missionary() 是否可以正确筛选可用的mission以及missionary"""
    not_valid_mission = create_not_valid_mission()
    valid_mission = create_valid_mission()
    save_many_models(not_valid_mission, valid_mission)

    is_end_missionary_valid = create_is_end_missionary(valid_mission.id)
    is_end_missionary_not_valid = create_is_end_missionary(
        not_valid_mission.id)
    not_end_missionary_valid = create_not_end_missionary(valid_mission.id)
    not_end_missionary_not_valid = create_not_end_missionary(
        not_valid_mission.id)
    save_many_models(is_end_missionary_valid, is_end_missionary_not_valid,
                     not_end_missionary_valid, not_end_missionary_not_valid)

    result = get_valid_mission_missionary()
    for d in result:
        assert d['mission'].is_valid is True
        assert d['mission'].id == valid_mission.id
        assert d['missionary'].is_end is False
        assert d['missionary'].id == not_end_missionary_valid.id