formatting, code optimized

This commit is contained in:
Frederik Jaeckel 2023-06-06 16:46:03 +02:00
parent 5c22c0fbb3
commit d9958b5ccf
5 changed files with 83 additions and 71 deletions

View file

@ -4,21 +4,14 @@
import trytond.tests.test_tryton
import unittest
from trytond.modules.cashbook_media.tests.test_line import LineTestCase
from .test_line import LineTestCase
__all__ = ['suite']
class CashbookTestCase(\
LineTestCase,
):
'Test cashbook module'
module = 'cashbook_media'
# end CashbookTestCase
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(CashbookTestCase))
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
LineTestCase))
return suite

View file

@ -5,9 +5,8 @@
from io import BytesIO
from PIL import Image
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.tests.test_tryton import with_transaction
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.exceptions import UserError
from trytond.modules.cashbook.tests import CashbookTestCase
from datetime import date
@ -126,8 +125,11 @@ class LineTestCase(CashbookTestCase):
self.assertEqual(book.state, 'open')
# add invalid file
self.assertRaisesRegex(UserError,
"The file type 'text/plain' of the record '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]' is not allowed. (allowed: PNG, JPG, PDF)",
self.assertRaisesRegex(
UserError,
"The file type 'text/plain' of the record " +
"'05/02/2022|Rev|1.00 usd|Text 2 [Cat1]' is not allowed. " +
"(allowed: PNG, JPG, PDF)",
Book.write,
*[
[book],
@ -146,8 +148,11 @@ class LineTestCase(CashbookTestCase):
])
# replace image at line-1 by invalid file
self.assertRaisesRegex(UserError,
"The file type 'text/plain' of the record '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]' is not allowed. (allowed: PNG, JPG, PDF)",
self.assertRaisesRegex(
UserError,
"The file type 'text/plain' of the record " +
"'05/02/2022|Rev|1.00 usd|Text 2 [Cat1]' is not allowed. " +
"(allowed: PNG, JPG, PDF)",
Lines.write,
*[
[book.lines[0]],
@ -163,7 +168,6 @@ class LineTestCase(CashbookTestCase):
"""
pool = Pool()
Book = pool.get('cashbook.book')
Lines = pool.get('cashbook.line')
types = self.prep_type()
category = self.prep_category(cattype='in')
@ -226,3 +230,6 @@ class LineTestCase(CashbookTestCase):
self.assertEqual(img2.size, (2000, 837))
# end LineTestCase
del CashbookTestCase