Exemplo n.º 1
0
def test_trial_heartbeat_not_updated(exp, trial):
    """Test that the heartbeat of a trial is not updated when trial is not longer reserved."""
    trial_monitor = TrialPacemaker(trial, wait_time=1)

    trial_monitor.start()
    time.sleep(2)

    trials = exp.fetch_trials_by_status("reserved")

    assert trial.heartbeat != trials[0].heartbeat

    get_storage().set_trial_status(trial, status="interrupted")

    time.sleep(2)

    # `join` blocks until all thread have finish executing. So, the test will hang if it fails.
    trial_monitor.join()
    assert 1
Exemplo n.º 2
0
def test_trial_heartbeat_not_updated(exp, trial):
    """Test that the heartbeat of a trial is not updated when trial is not longer reserved."""
    trial_monitor = TrialPacemaker(exp, trial.id, wait_time=1)

    trial_monitor.start()
    time.sleep(2)

    trials = exp.fetch_trials({'_id': trial.id, 'status': 'reserved'})

    assert trial.heartbeat != trials[0].heartbeat

    data = {'status': 'interrupted'}
    Database().write('trials', data, query=dict(_id=trial.id))

    time.sleep(2)

    # `join` blocks until all thread have finish executing. So, the test will hang if it fails.
    trial_monitor.join()
    assert 1