Improve tests, update migrations
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from ..classes import ControlCode
|
||||
|
||||
|
||||
class ControlCodeTest(ControlCode):
|
||||
arguments = ('argument_1',)
|
||||
label = 'Test'
|
||||
name = 'test'
|
||||
|
||||
def execute(self, context):
|
||||
pass
|
||||
|
||||
|
||||
ControlCode.register(control_code=ControlCodeTest)
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from ..classes import ControlCode
|
||||
from ..models import ControlSheet
|
||||
|
||||
from .control_codes import ControlCodeTest
|
||||
from .literals import (
|
||||
TEST_CONTROL_SHEET_CODE_ARGUMENTS,
|
||||
TEST_CONTROL_SHEET_CODE_ARGUMENTS_EDITED, TEST_CONTROL_SHEET_LABEL,
|
||||
@@ -10,15 +10,6 @@ from .literals import (
|
||||
)
|
||||
|
||||
|
||||
class ControlCodeTest(ControlCode):
|
||||
arguments = ('argument_1',)
|
||||
label = 'Test'
|
||||
name = 'test'
|
||||
|
||||
def execute(self):
|
||||
pass
|
||||
|
||||
|
||||
class ControlSheetAPIViewTestMixin(object):
|
||||
def _request_test_control_sheet_create_api_view(self):
|
||||
return self.post(
|
||||
@@ -137,7 +128,6 @@ class ControlSheetCodeViewTestMixin(object):
|
||||
'control_sheet_id': self.test_control_sheet.pk,
|
||||
'control_code_class_name': self._test_control_code_class.name
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
def _request_test_control_sheet_code_delete_view(self):
|
||||
@@ -165,6 +155,3 @@ class ControlSheetCodeViewTestMixin(object):
|
||||
'control_sheet_id': self.test_control_sheet.pk
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
ControlCode.register(control_code=ControlCodeTest)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.documents.tests.base import GenericDocumentTestCase
|
||||
from mayan.apps.storage.utils import fs_cleanup, mkstemp
|
||||
|
||||
from ..control_codes import ControlCodeAttributeEdit
|
||||
|
||||
|
||||
class ControlCodeAttributeEditTestCase(GenericDocumentTestCase):
|
||||
auto_upload_document = False
|
||||
|
||||
def setUp(self):
|
||||
super(ControlCodeAttributeEditTestCase, self).setUp()
|
||||
self.test_document_path = mkstemp()[1]
|
||||
|
||||
def tearDown(self):
|
||||
fs_cleanup(filename=self.test_document_path)
|
||||
super(ControlCodeAttributeEditTestCase, self).tearDown()
|
||||
|
||||
def test_control_code(self):
|
||||
TEST_ATTRIBUTE_VALUE = 'test value'
|
||||
|
||||
with open(self.test_document_path, mode='wb') as file_object:
|
||||
control_code = ControlCodeAttributeEdit(
|
||||
name='label', value=TEST_ATTRIBUTE_VALUE
|
||||
)
|
||||
control_code.get_image().save(file_object)
|
||||
|
||||
self.upload_document()
|
||||
self.test_document.refresh_from_db()
|
||||
self.assertEqual(self.test_document.label, TEST_ATTRIBUTE_VALUE)
|
||||
@@ -1,45 +0,0 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.common.tests.base import BaseTestCase
|
||||
from mayan.apps.documents.tests.base import GenericDocumentTestCase
|
||||
|
||||
from ..control_codes import ControlCodeAttributeEdit
|
||||
|
||||
from .mixins import ControlSheetCodeTestMixin
|
||||
|
||||
#TODO: use mktmp
|
||||
TEST_CONTROL_CODE_DOCUMENT_PATH = '/tmp/test_control_code.png'
|
||||
|
||||
"""
|
||||
class ControlCodeTestCase(ControlSheetCodeTestMixin, GenericDocumentTestCase):
|
||||
auto_upload_document = False
|
||||
test_document_path = TEST_CONTROL_CODE_DOCUMENT_PATH
|
||||
|
||||
def test_control_code_detection(self):
|
||||
with open(TEST_CONTROL_CODE_DOCUMENT_PATH, mode='wb') as file_object:
|
||||
control_code = self._test_control_code_class(
|
||||
argument_1='test argument value'
|
||||
)
|
||||
control_code.get_image().save(file_object)
|
||||
|
||||
self.upload_document()
|
||||
|
||||
print self.test_document.pages.count()
|
||||
"""
|
||||
|
||||
class ControlCodeAttributeEditTestCase(GenericDocumentTestCase):
|
||||
auto_upload_document = False
|
||||
test_document_path = TEST_CONTROL_CODE_DOCUMENT_PATH
|
||||
|
||||
def test_control_code(self):
|
||||
TEST_ATTRIBUTE_VALUE = 'test value'
|
||||
|
||||
with open(TEST_CONTROL_CODE_DOCUMENT_PATH, mode='wb') as file_object:
|
||||
control_code = ControlCodeAttributeEdit(
|
||||
attribute='label', value=TEST_ATTRIBUTE_VALUE
|
||||
)
|
||||
control_code.get_image().save(file_object)
|
||||
|
||||
self.upload_document()
|
||||
self.test_document.refresh_from_db()
|
||||
self.assertEqual(self.test_document.label, TEST_ATTRIBUTE_VALUE)
|
||||
Reference in New Issue
Block a user