Skip to content

Commit

Permalink
add basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Sikora committed Oct 20, 2014
1 parent 6d12461 commit 844cb51
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
20 changes: 16 additions & 4 deletions django_cron/tests.py
@@ -1,10 +1,22 @@
from django.utils import unittest
from django_cron.models import CronJobLog
from django.core.management import call_command


class SimpleTestCase(unittest.TestCase):
class TestCase(unittest.TestCase):

success_cron = 'test_crons.TestSucessCronJob'
error_cron = 'test_crons.TestErrorCronJob'

def setUp(self):
pass

def test_example(self):
"""Some test example"""
pass
def test_success_cron(self):
lgos_count = CronJobLog.objects.all().count()
call_command('runcrons', self.success_cron, force=True)
self.assertEqual(CronJobLog.objects.all().count(), lgos_count + 1)

def test_failed_cron(self):
lgos_count = CronJobLog.objects.all().count()
call_command('runcrons', self.error_cron, force=True)
self.assertEqual(CronJobLog.objects.all().count(), lgos_count + 1)
17 changes: 17 additions & 0 deletions test_crons.py
@@ -0,0 +1,17 @@
from django_cron import CronJobBase, Schedule


class TestSucessCronJob(CronJobBase):
code = 'test_success_cron_job'
schedule = Schedule(run_every_mins=0)

def do(self):
pass


class TestErrorCronJob(CronJobBase):
code = 'test_error_cron_job'
schedule = Schedule(run_every_mins=0)

def do(self):
raise
6 changes: 6 additions & 0 deletions test_settings.py
Expand Up @@ -15,3 +15,9 @@
]

SECRET_KEY = "wknfgl34qtnjo&Yk3jqfjtn2k3jtnk4wtnk"


CRON_CLASSES = [
'test_crons.TestSucessCronJob',
'test_crons.TestErrorCronJob',
]

0 comments on commit 844cb51

Please sign in to comment.