示例#1
0
def test_start(test_data):
    workout = Workout(test_data + '/basic.yml')
    workout.start()
    sleep(0.01)

    assert workout.current_interval() == workout.intervals[0]
    assert workout.elapsed() == approx_time(0.01)
示例#2
0
def test_yaml_basic(test_data):
    n_intervals = 4
    names = ['One', 'Two', 'Three', 'Four']
    workout = Workout(yaml_file=test_data+'/basic.yml')
    interval_names = [interval.text for interval in workout.intervals]

    assert len(workout.intervals) == n_intervals
    assert interval_names == names
示例#3
0
def test_yaml_block(test_data):
    n_intervals = 6
    names = ['One', 'Two'] + ['Block One', 'Block Two']*2
    workout = Workout(yaml_file=test_data+'/block.yml')
    interval_names = [interval.text for interval in workout.intervals]

    assert len(workout.intervals) == n_intervals
    assert interval_names == names
示例#4
0
def test_ending(test_data):
    workout = Workout(yaml_file=test_data + '/quick.yml')
    workout.start()
    sleep(0.03)

    workout.progress()

    assert workout.state == WorkoutState.stopped
示例#5
0
def test_upcoming(test_data):
    workout = Workout(yaml_file=test_data + '/quick.yml')

    assert workout.upcoming() == workout.intervals[1:]

    workout.start()
    sleep(0.01)

    assert workout.upcoming() == workout.intervals[2:]
示例#6
0
def test_pause(test_data):
    workout = Workout(yaml_file=test_data + '/basic.yml')
    workout.start()
    sleep(0.01)
    workout.pause()
    sleep(0.01)

    assert workout.state == WorkoutState.paused
    assert workout.elapsed() == approx_time(0.01)
示例#7
0
def test_transition(test_data):
    workout = Workout(yaml_file=test_data + '/quick.yml')
    workout.start()
    sleep(0.01)

    progress = workout.progress()

    assert workout.current_interval() == workout.intervals[1]
    assert progress.changed_interval
示例#8
0
def test_resume(test_data):
    workout = Workout(yaml_file=test_data + '/basic.yml')
    workout.start()
    sleep(0.01)
    workout.pause()
    sleep(0.01)
    workout.start()

    assert workout.time_paused == approx_time(0.01)
    assert workout.state == WorkoutState.running
示例#9
0
def main():
    os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"

    app = QtWidgets.QApplication(sys.argv)

    # Get command line arguments
    clargs = parse_args()
    # Create workout object
    workout = Workout(clargs.workout)

    ui = Ui(workout)  # noqa: F841
    sys.exit(app.exec_())
示例#10
0
def test_yaml_nested_blocks(test_data):
    n_intervals = 12
    names = (
        ['One', 'Two']
        + (
            ['Block One']
            + ['Nested Block One', 'Nested Block Two']*2
        )*2
    )
    workout = Workout(yaml_file=test_data+'/nested_blocks.yml')
    interval_names = [interval.text for interval in workout.intervals]

    assert len(workout.intervals) == n_intervals
    assert interval_names == names
示例#11
0
def test_progress(test_data):
    workout = Workout(yaml_file=test_data + '/quick.yml')
    workout.start()
    sleep(0.01)

    progress = workout.progress()

    assert progress.elapsed == approx_time(0.01)
    assert progress.remaining == approx_time(0.02)
    assert progress.interval_elapsed == approx_time(0.)
    assert progress.interval_remaining == approx_time(0.01)
    assert progress.interval == workout.intervals[1]
    assert progress.changed_interval is True

    progress = workout.progress()

    assert progress.changed_interval is False
示例#12
0
 def test_block_missing_intervals(self, test_data):
     with pytest.raises(MissingKeyError):
         Workout(yaml_file=test_data+'/block_missing_intervals.yml')
示例#13
0
 def test_missing_interval_key(self, test_data):
     with pytest.raises(MissingKeyError):
         Workout(yaml_file=test_data+'/missing_interval_key.yml')
示例#14
0
def test_invalid_yaml(test_data):
    with pytest.raises(WorkoutFileError):
        Workout(yaml_file=test_data+'/invalid_yaml.yml')