Commit 1b94666c by J. Cliff Dyer

Use mock's ANY

parent 7127ab86
...@@ -9,7 +9,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera ...@@ -9,7 +9,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import ddt import ddt
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.core.management import CommandError, call_command from django.core.management import CommandError, call_command
from mock import patch from mock import ANY, patch
import six import six
from student.models import CourseEnrollment from student.models import CourseEnrollment
...@@ -27,14 +27,6 @@ def _sorted_by_batch(calls): ...@@ -27,14 +27,6 @@ def _sorted_by_batch(calls):
return sorted(calls, key=lambda x: (x[1]['kwargs']['course_key'], x[1]['kwargs']['offset'])) return sorted(calls, key=lambda x: (x[1]['kwargs']['course_key'], x[1]['kwargs']['offset']))
class Any(object):
"""
Dummy object that compares equal to all other objects.
"""
def __eq__(self, other):
return True
@ddt.ddt @ddt.ddt
class TestComputeGrades(SharedModuleStoreTestCase): class TestComputeGrades(SharedModuleStoreTestCase):
""" """
...@@ -109,7 +101,7 @@ class TestComputeGrades(SharedModuleStoreTestCase): ...@@ -109,7 +101,7 @@ class TestComputeGrades(SharedModuleStoreTestCase):
'batch_size': 2, 'batch_size': 2,
'offset': offset, 'offset': offset,
'estimate_first_attempted': estimate_first_attempted, 'estimate_first_attempted': estimate_first_attempted,
'seq_id': Any(), 'seq_id': ANY,
} }
self.assertEqual( self.assertEqual(
_sorted_by_batch(mock_task.apply_async.call_args_list), _sorted_by_batch(mock_task.apply_async.call_args_list),
...@@ -146,7 +138,7 @@ class TestComputeGrades(SharedModuleStoreTestCase): ...@@ -146,7 +138,7 @@ class TestComputeGrades(SharedModuleStoreTestCase):
'batch_size': 2, 'batch_size': 2,
'offset': 0, 'offset': 0,
'estimate_first_attempted': True, 'estimate_first_attempted': True,
'seq_id': Any(), 'seq_id': ANY,
}, },
},), },),
({ ({
...@@ -155,7 +147,7 @@ class TestComputeGrades(SharedModuleStoreTestCase): ...@@ -155,7 +147,7 @@ class TestComputeGrades(SharedModuleStoreTestCase):
'batch_size': 2, 'batch_size': 2,
'offset': 2, 'offset': 2,
'estimate_first_attempted': True, 'estimate_first_attempted': True,
'seq_id': Any(), 'seq_id': ANY,
}, },
},), },),
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment