Skip to content

Commit

Permalink
add seconds option to interval_units with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Egan committed Oct 10, 2018
1 parent fa76c6a commit 83cc432
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ target/

# SQLite
*.sqlite3

# Pipenv
Pipfile
Pipfile.lock
18 changes: 18 additions & 0 deletions scheduler/migrations/0006_auto_20181010_0102.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.2 on 2018-10-10 01:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('scheduler', '0005_added_result_ttl'),
]

operations = [
migrations.AlterField(
model_name='repeatablejob',
name='interval_unit',
field=models.CharField(choices=[('seconds', 'seconds'), ('minutes', 'minutes'), ('hours', 'hours'), ('days', 'days'), ('weeks', 'weeks')], default='hours', max_length=12, verbose_name='interval unit'),
),
]
1 change: 1 addition & 0 deletions scheduler/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class Meta:
class RepeatableJob(ScheduledTimeMixin, BaseJob):

UNITS = Choices(
('seconds', _('seconds')),
('minutes', _('minutes')),
('hours', _('hours')),
('days', _('days')),
Expand Down
6 changes: 6 additions & 0 deletions scheduler/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ def test_interval_seconds_minutes(self):
job.interval_unit = 'minutes'
self.assertEqual(900.0, job.interval_seconds())

def test_interval_seconds_seconds(self):
job = RepeatableJob()
job.interval = 15
job.interval_unit = 'seconds'
self.assertEqual(15.0, job.interval_seconds())

def test_repeatable_schedule(self):
job = self.JobClassFactory()
job.id = 1
Expand Down

0 comments on commit 83cc432

Please sign in to comment.