Skip to content

Commit

Permalink
Add test case that bulk_create ids are not none
Browse files Browse the repository at this point in the history
  • Loading branch information
wichmannpas committed Sep 6, 2018
1 parent edc2a3d commit e7a1968
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions task/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3552,6 +3552,44 @@ def setUp(self):
name='Testtask',
duration=Decimal(2))

@freeze_time('2010-05-03')
def test_defined_ids(self):
"""
Test that the scheduled chunks returned from the API contain id values.
This test *will fail* on database backends that are not supported,
such as sqlite.
"""
self.assertEqual(
TaskChunkSeries.objects.count(),
0)
self.assertEqual(
TaskChunk.objects.count(),
0)

resp = self.client.post('/task/chunk/series/', {
'task_id': self.task.pk,
'duration': '2',
'start': '2010-05-23',
'end': '2010-06-23',
'rule': 'interval',
'interval_days': 1,
})
self.assertEqual(
resp.status_code,
status.HTTP_201_CREATED)

self.assertSetEqual(
set(resp.data.keys()),
{'series', 'scheduled'})

self.assertEqual(
len(resp.data['scheduled']),
32)

for scheduled in resp.data['scheduled']:
self.assertIsNotNone(scheduled['id'])
self.assertIsInstance(scheduled['id'], int)

@freeze_time('2010-05-03')
def test_create(self):
"""
Expand Down

0 comments on commit e7a1968

Please sign in to comment.