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)
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
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
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
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:]
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)
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
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
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_())
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
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
def test_block_missing_intervals(self, test_data): with pytest.raises(MissingKeyError): Workout(yaml_file=test_data+'/block_missing_intervals.yml')
def test_missing_interval_key(self, test_data): with pytest.raises(MissingKeyError): Workout(yaml_file=test_data+'/missing_interval_key.yml')
def test_invalid_yaml(test_data): with pytest.raises(WorkoutFileError): Workout(yaml_file=test_data+'/invalid_yaml.yml')