def test_get_total_ignore_filter(self): step = UnitPublishStep("foo", ['bar', 'baz']) step.association_filters = {'foo': 'bar'} step.parent = Mock() step.parent.repo.content_unit_counts.get.return_value = 1 total = step._get_total(ignore_filter=True) self.assertEquals(2, total)
def test_get_with_association_filter(self, mock_manager_factory): step = UnitPublishStep("foo", ['bar', 'baz']) step.association_filters = {'foo': 'bar'} find_by_criteria = mock_manager_factory.repo_unit_association_query_manager.return_value.\ find_by_criteria find_by_criteria.return_value.count.return_value = 5 total = step._get_total() criteria_object = find_by_criteria.call_args[0][0] compare_dict(criteria_object.filters, {'foo': 'bar', 'unit_type_id': {'$in': ['bar', 'baz']}}) self.assertEquals(5, total)
def test_get_total_for_none(self): step = UnitPublishStep("foo", ['bar', 'baz']) step.parent = Mock() step.parent.repo.content_unit_counts.get.return_value = 0 total = step._get_total() self.assertEquals(0, total)
def test_get_with_association_filter(self): step = UnitPublishStep("foo", ['bar', 'baz']) step.association_filters = {'foo': 'bar'} total = step._get_total() self.assertEquals(1, total)