Reorganize and improve checkouts tests
Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -4,13 +4,37 @@ import datetime
|
||||
|
||||
from django.utils.timezone import now
|
||||
|
||||
from mayan.apps.common.literals import TIME_DELTA_UNIT_DAYS
|
||||
|
||||
from ..models import DocumentCheckout
|
||||
|
||||
|
||||
class DocumentCheckoutsAPIViewTestMixin(object):
|
||||
def _request_checkedout_document_view(self):
|
||||
return self.get(
|
||||
viewname='rest_api:checkedout-document-view',
|
||||
kwargs={'pk': self.test_check_out.pk}
|
||||
)
|
||||
|
||||
def _request_test_document_check_out_view(self):
|
||||
return self.post(
|
||||
viewname='rest_api:checkout-document-list', data={
|
||||
'document_pk': self.test_document.pk,
|
||||
'expiration_datetime': '2099-01-01T12:00'
|
||||
}
|
||||
)
|
||||
|
||||
def _request_checkout_list_view(self):
|
||||
return self.get(viewname='rest_api:checkout-document-list')
|
||||
|
||||
|
||||
class DocumentCheckoutTestMixin(object):
|
||||
_test_document_check_out_seconds = 0.1
|
||||
|
||||
def _check_out_test_document(self, user=None):
|
||||
def _check_out_test_document(self, document=None, user=None):
|
||||
if not document:
|
||||
document = self.test_document
|
||||
|
||||
if not user:
|
||||
user = self._test_case_user
|
||||
|
||||
@@ -19,7 +43,44 @@ class DocumentCheckoutTestMixin(object):
|
||||
)
|
||||
|
||||
self.test_check_out = DocumentCheckout.objects.check_out_document(
|
||||
block_new_version=True, document=self.test_document,
|
||||
block_new_version=True, document=document,
|
||||
expiration_datetime=self._check_out_expiration_datetime,
|
||||
user=user
|
||||
)
|
||||
|
||||
|
||||
class DocumentCheckoutViewTestMixin(object):
|
||||
def _request_test_document_check_in_get_view(self):
|
||||
return self.get(
|
||||
viewname='checkouts:check_in_document', kwargs={
|
||||
'pk': self.test_document.pk
|
||||
}
|
||||
)
|
||||
|
||||
def _request_test_document_check_in_post_view(self):
|
||||
return self.post(
|
||||
viewname='checkouts:check_in_document', kwargs={
|
||||
'pk': self.test_document.pk
|
||||
}
|
||||
)
|
||||
|
||||
def _request_test_document_check_out_detail_view(self):
|
||||
return self.get(
|
||||
viewname='checkouts:check_out_info', kwargs={
|
||||
'pk': self.test_document.pk
|
||||
}
|
||||
)
|
||||
|
||||
def _request_test_document_check_out_list_view(self):
|
||||
return self.get(viewname='checkouts:check_out_list')
|
||||
|
||||
def _request_test_document_check_out_view(self):
|
||||
return self.post(
|
||||
viewname='checkouts:check_out_document', kwargs={
|
||||
'pk': self.test_document.pk
|
||||
}, data={
|
||||
'expiration_datetime_unit': TIME_DELTA_UNIT_DAYS,
|
||||
'expiration_datetime_amount': 99,
|
||||
'block_new_version': True
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user