1409
1409
self.assertEqual(sorted(expected), sorted(tasks))
1411
@patch('webcatalog.management.commands.import_exhibits.urllib.urlopen')
1412
def test_post_schedules_task(self, mock_urlopen):
1413
fd = mock_urlopen.return_value
1415
fd.read.return_value = "[]"
1411
@patch('webcatalog.tasks.call_command')
1412
def test_post_schedules_task(self, mock_call_command):
1416
1413
self.make_user(permissions=['schedule_tasks'], logged_in=True)
1417
1414
url = reverse('wc-tasks')
1418
1415
data = {'task': 'import_exhibits'}
1420
response = self.client.post(url, data=data, follow=True)
1417
response = self.client.post(url, data=data, follow=False)
1419
messages_cookie = response.client.cookies['messages'].output()
1422
1420
msg_pat = r'Task id <span>[-\da-f]+</span> submitted'
1423
match = re.search(msg_pat, response.content)
1421
match = re.search(msg_pat, messages_cookie)
1424
1422
self.assertFalse(match is None)
1425
self.assertEqual(1, mock_urlopen.call_count)
1423
self.assertEqual(1, mock_call_command.call_count)
1428
1426
class TaskStatusViewTestCase(TestCaseWithFactory):