def test_prepere_after_filter(self): """ Django will reset related selects when a filter is added """ queryset = MagicMock() queryset_resource = ComplexUserResourceQuerySetResource(queryset) queryset_resource.get(mock_context(), EmptyParams()) calls = call.all().distinct().filter().select_related('manager').prefetch_related('reports').call_list() queryset.assert_has_calls(calls)
def test_find_usage(self): mock_buckets = Mock() mock_buckets.all.return_value = ['a', 'b', 'c'] mock_conn = Mock(buckets=mock_buckets) with patch('%s.connect_resource' % pb) as mock_connect: cls = _S3Service(21, 43) cls.resource_conn = mock_conn assert cls._have_usage is False cls.find_usage() assert mock_connect.mock_calls == [call()] assert cls._have_usage is True assert mock_buckets.mock_calls == [call.all()] assert len(cls.limits['Buckets'].get_current_usage()) == 1 assert cls.limits['Buckets'].get_current_usage()[0].get_value() == 3