Skip to content

Add unit tests for CronJob.duration and CronJob.elapsed properties #160

@coderabbitai

Description

@coderabbitai

Background

The CronJob class in supertask/model.py has properties (duration, elapsed) and a method (delta_duration) that currently lack test coverage.

Required Tests

Unit tests should be added to cover:

  • Finished job: When end is set, duration should return (end – start).total_seconds().
  • Unfinished job: When end is None, duration should raise RuntimeError("Job has not finished yet").
  • Elapsed time: When end is None, elapsed should return (now – start).total_seconds() without raising an exception.
  • delta_duration: Conversion of a timedelta to seconds (e.g., 1 hour → 3600 seconds).

Suggested Implementation

Create tests under tests/ (e.g., tests/test_cronjob.py) that exercise these scenarios.

References

This issue was identified during code review:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions