[IMP] base_report_to_printer: black, isort, prettier

This commit is contained in:
David Montull
2022-03-03 17:17:43 +01:00
committed by John Herholz
parent 535e2c9d5d
commit 3a22073a87
12 changed files with 51 additions and 51 deletions

View File

@@ -35,7 +35,7 @@ class IrActionsReport(models.Model):
@api.onchange("printing_printer_id") @api.onchange("printing_printer_id")
def onchange_printing_printer_id(self): def onchange_printing_printer_id(self):
""" Reset the tray when the printer is changed """ """Reset the tray when the printer is changed"""
self.printer_tray_id = False self.printer_tray_id = False
@api.model @api.model
@@ -99,7 +99,7 @@ class IrActionsReport(models.Model):
return result return result
def print_document(self, record_ids, data=None): def print_document(self, record_ids, data=None):
""" Print a document, do not return the document file """ """Print a document, do not return the document file"""
document, doc_format = self.with_context( document, doc_format = self.with_context(
must_skip_send_to_printer=True must_skip_send_to_printer=True
)._render_qweb_pdf(record_ids, data=data) )._render_qweb_pdf(record_ids, data=data)

View File

@@ -173,7 +173,7 @@ class PrintingPrinter(models.Model):
return options return options
def print_file(self, file_name, report=None, **print_opts): def print_file(self, file_name, report=None, **print_opts):
""" Print a file """ """Print a file"""
self.ensure_one() self.ensure_one()
title = print_opts.pop("title", file_name) title = print_opts.pop("title", file_name)
connection = self.server_id._open_connection(raise_on_error=True) connection = self.server_id._open_connection(raise_on_error=True)

View File

@@ -35,7 +35,7 @@ class PrintingReportXmlAction(models.Model):
@api.onchange("printer_id") @api.onchange("printer_id")
def onchange_printer_id(self): def onchange_printer_id(self):
""" Reset the tray when the printer is changed """ """Reset the tray when the printer is changed"""
self.printer_tray_id = False self.printer_tray_id = False
def behaviour(self): def behaviour(self):

View File

@@ -38,5 +38,5 @@ class ResUsers(models.Model):
@api.onchange("printing_printer_id") @api.onchange("printing_printer_id")
def onchange_printing_printer_id(self): def onchange_printing_printer_id(self):
""" Reset the tray when the printer is changed """ """Reset the tray when the printer is changed"""
self.printer_tray_id = False self.printer_tray_id = False

View File

@@ -54,14 +54,14 @@ class TestIrActionsReportXml(TransactionCase):
return self.env["printing.tray"].create(values) return self.env["printing.tray"].create(values)
def test_print_action_for_report_name_gets_report(self): def test_print_action_for_report_name_gets_report(self):
""" It should get report by name """ """It should get report by name"""
with mock.patch("%s._get_report_from_name" % model) as mk: with mock.patch("%s._get_report_from_name" % model) as mk:
expect = "test" expect = "test"
self.Model.print_action_for_report_name(expect) self.Model.print_action_for_report_name(expect)
mk.assert_called_once_with(expect) mk.assert_called_once_with(expect)
def test_print_action_for_report_name_returns_if_no_report(self): def test_print_action_for_report_name_returns_if_no_report(self):
""" It should return empty dict when no matching report """ """It should return empty dict when no matching report"""
with mock.patch("%s._get_report_from_name" % model) as mk: with mock.patch("%s._get_report_from_name" % model) as mk:
expect = "test" expect = "test"
mk.return_value = False mk.return_value = False
@@ -69,7 +69,7 @@ class TestIrActionsReportXml(TransactionCase):
self.assertDictEqual({}, res) self.assertDictEqual({}, res)
def test_print_action_for_report_name_returns_if_report(self): def test_print_action_for_report_name_returns_if_report(self):
""" It should return correct serializable result for behaviour """ """It should return correct serializable result for behaviour"""
with mock.patch("%s._get_report_from_name" % model) as mk: with mock.patch("%s._get_report_from_name" % model) as mk:
res = self.Model.print_action_for_report_name("test") res = self.Model.print_action_for_report_name("test")
behaviour = mk().behaviour() behaviour = mk().behaviour()
@@ -80,7 +80,7 @@ class TestIrActionsReportXml(TransactionCase):
self.assertDictEqual(expect, res, "Expect {}, Got {}".format(expect, res)) self.assertDictEqual(expect, res, "Expect {}, Got {}".format(expect, res))
def test_behaviour_default_values(self): def test_behaviour_default_values(self):
""" It should return the default action and printer """ """It should return the default action and printer"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = False self.env.user.printing_action = False
self.env.user.printing_printer_id = False self.env.user.printing_printer_id = False
@@ -96,7 +96,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_user_values(self): def test_behaviour_user_values(self):
""" It should return the action and printer from user """ """It should return the action and printer from user"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
self.env.user.printing_printer_id = self.new_printer() self.env.user.printing_printer_id = self.new_printer()
@@ -110,7 +110,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_report_values(self): def test_behaviour_report_values(self):
""" It should return the action and printer from report """ """It should return the action and printer from report"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
report.property_printing_action_id = self.new_action() report.property_printing_action_id = self.new_action()
@@ -125,7 +125,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_user_action(self): def test_behaviour_user_action(self):
""" It should return the action and printer from user action""" """It should return the action and printer from user action"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
report.property_printing_action_id.action_type = "user_default" report.property_printing_action_id.action_type = "user_default"
@@ -180,7 +180,7 @@ class TestIrActionsReportXml(TransactionCase):
) )
def test_behaviour_printing_action_with_printer(self): def test_behaviour_printing_action_with_printer(self):
""" It should return the action and printer from printing action """ """It should return the action and printer from printing action"""
report = self.Model.search([], limit=1) report = self.Model.search([], limit=1)
self.env.user.printing_action = "client" self.env.user.printing_action = "client"
printing_action = self.new_printing_action() printing_action = self.new_printing_action()

View File

@@ -44,7 +44,7 @@ class TestPrintingJob(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_cancel_job_error(self, cups): def test_cancel_job_error(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
printer = self.new_printer() printer = self.new_printer()
job = self.new_job(printer, {"job_id_cups": 2}) job = self.new_job(printer, {"job_id_cups": 2})
@@ -54,7 +54,7 @@ class TestPrintingJob(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_cancel_job(self, cups): def test_cancel_job(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
printer = self.new_printer() printer = self.new_printer()
job = self.new_job(printer) job = self.new_job(printer)
job.cancel() job.cancel()

View File

@@ -64,7 +64,7 @@ class TestPrintingPrinter(TransactionCase):
self.assertEqual(self.Model._set_option_format(None, "pdf"), {}) self.assertEqual(self.Model._set_option_format(None, "pdf"), {})
def test_print_options(self): def test_print_options(self):
""" It should generate the right options dictionnary """ """It should generate the right options dictionnary"""
# TODO: None here used as report - tests here should be merged # TODO: None here used as report - tests here should be merged
# with tests in test_printing_printer_tray from when modules merged # with tests in test_printing_printer_tray from when modules merged
report = self.env["ir.actions.report"].search([], limit=1) report = self.env["ir.actions.report"].search([], limit=1)
@@ -81,7 +81,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_report(self, cups): def test_print_report(self, cups):
""" It should print a report through CUPS """ """It should print a report through CUPS"""
fd, file_name = tempfile.mkstemp() fd, file_name = tempfile.mkstemp()
with mock.patch("%s.mkstemp" % model) as mkstemp: with mock.patch("%s.mkstemp" % model) as mkstemp:
mkstemp.return_value = fd, file_name mkstemp.return_value = fd, file_name
@@ -93,7 +93,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_report_error(self, cups): def test_print_report_error(self, cups):
""" It should print a report through CUPS """ """It should print a report through CUPS"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
fd, file_name = tempfile.mkstemp() fd, file_name = tempfile.mkstemp()
with mock.patch("%s.mkstemp" % model) as mkstemp: with mock.patch("%s.mkstemp" % model) as mkstemp:
@@ -106,7 +106,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_file(self, cups): def test_print_file(self, cups):
""" It should print a file through CUPS """ """It should print a file through CUPS"""
file_name = "file_name" file_name = "file_name"
printer = self.new_record() printer = self.new_record()
printer.print_file(file_name, "pdf") printer.print_file(file_name, "pdf")
@@ -116,7 +116,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_file_error(self, cups): def test_print_file_error(self, cups):
""" It should print a file through CUPS """ """It should print a file through CUPS"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
file_name = "file_name" file_name = "file_name"
printer = self.new_record() printer = self.new_record()
@@ -124,7 +124,7 @@ class TestPrintingPrinter(TransactionCase):
printer.print_file(file_name) printer.print_file(file_name)
def test_set_default(self): def test_set_default(self):
""" It should set a single record as default """ """It should set a single record as default"""
printer = self.new_record() printer = self.new_record()
self.assertTrue(printer.default) self.assertTrue(printer.default)
other_printer = self.new_record() other_printer = self.new_record()
@@ -136,7 +136,7 @@ class TestPrintingPrinter(TransactionCase):
self.assertEqual(other_printer, self.Model.get_default()) self.assertEqual(other_printer, self.Model.get_default())
def test_unset_default(self): def test_unset_default(self):
""" It should unset the default state of the printer """ """It should unset the default state of the printer"""
printer = self.new_record() printer = self.new_record()
self.assertTrue(printer.default) self.assertTrue(printer.default)
printer.unset_default() printer.unset_default()
@@ -144,7 +144,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_cancel_all_jobs(self, cups): def test_cancel_all_jobs(self, cups):
""" It should cancel all jobs """ """It should cancel all jobs"""
printer = self.new_record() printer = self.new_record()
printer.action_cancel_all_jobs() printer.action_cancel_all_jobs()
cups.Connection().cancelAllJobs.assert_called_once_with( cups.Connection().cancelAllJobs.assert_called_once_with(
@@ -153,7 +153,7 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_cancel_and_purge_all_jobs(self, cups): def test_cancel_and_purge_all_jobs(self, cups):
""" It should cancel all jobs """ """It should cancel all jobs"""
printer = self.new_record() printer = self.new_record()
printer.cancel_all_jobs(purge_jobs=True) printer.cancel_all_jobs(purge_jobs=True)
cups.Connection().cancelAllJobs.assert_called_once_with( cups.Connection().cancelAllJobs.assert_called_once_with(
@@ -162,21 +162,21 @@ class TestPrintingPrinter(TransactionCase):
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_enable_printer(self, cups): def test_enable_printer(self, cups):
""" It should enable the printer """ """It should enable the printer"""
printer = self.new_record() printer = self.new_record()
printer.enable() printer.enable()
cups.Connection().enablePrinter.assert_called_once_with(printer.system_name) cups.Connection().enablePrinter.assert_called_once_with(printer.system_name)
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_disable_printer(self, cups): def test_disable_printer(self, cups):
""" It should disable the printer """ """It should disable the printer"""
printer = self.new_record() printer = self.new_record()
printer.disable() printer.disable()
cups.Connection().disablePrinter.assert_called_once_with(printer.system_name) cups.Connection().disablePrinter.assert_called_once_with(printer.system_name)
@mock.patch("%s.cups" % server_model) @mock.patch("%s.cups" % server_model)
def test_print_test_page(self, cups): def test_print_test_page(self, cups):
""" It should print a test page """ """It should print a test page"""
printer = self.new_record() printer = self.new_record()
printer.print_test_page() printer.print_test_page()
cups.Connection().printTestPage.assert_called_once_with(printer.system_name) cups.Connection().printTestPage.assert_called_once_with(printer.system_name)

View File

@@ -38,7 +38,7 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_inits_connection(self, cups): def test_action_ok_inits_connection(self, cups):
""" It should initialize CUPS connection """ """It should initialize CUPS connection"""
self.Model.action_ok() self.Model.action_ok()
cups.Connection.assert_called_once_with( cups.Connection.assert_called_once_with(
host=self.server.address, port=self.server.port host=self.server.address, port=self.server.port
@@ -46,7 +46,7 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_gets_printers(self, cups): def test_action_ok_gets_printers(self, cups):
""" It should get printers from CUPS """ """It should get printers from CUPS"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals} cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
cups.Connection().getPPD3.return_value = (200, 0, "") cups.Connection().getPPD3.return_value = (200, 0, "")
self.Model.action_ok() self.Model.action_ok()
@@ -54,14 +54,14 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_raises_warning_on_error(self, cups): def test_action_ok_raises_warning_on_error(self, cups):
""" It should raise Warning on any error """ """It should raise Warning on any error"""
cups.Connection.side_effect = StopTest cups.Connection.side_effect = StopTest
with self.assertRaises(UserError): with self.assertRaises(UserError):
self.Model.action_ok() self.Model.action_ok()
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_creates_new_printer(self, cups): def test_action_ok_creates_new_printer(self, cups):
""" It should create new printer w/ proper vals """ """It should create new printer w/ proper vals"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals} cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
cups.Connection().getPPD3.return_value = (200, 0, "") cups.Connection().getPPD3.return_value = (200, 0, "")
self.Model.action_ok() self.Model.action_ok()
@@ -77,7 +77,7 @@ class TestPrintingPrinterWizard(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_action_ok_skips_existing_printer(self, cups): def test_action_ok_skips_existing_printer(self, cups):
""" It should not recreate existing printers """ """It should not recreate existing printers"""
cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals} cups.Connection().getPrinters.return_value = {"sys_name": self.printer_vals}
cups.Connection().getPPD3.return_value = (200, 0, "") cups.Connection().getPPD3.return_value = (200, 0, "")
self.env["printing.printer"].create(self._record_vals()) self.env["printing.printer"].create(self._record_vals())

View File

@@ -45,7 +45,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_error(self, cups): def test_update_printers_error(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
rec_id = self.new_printer() rec_id = self.new_printer()
self.Model.update_printers() self.Model.update_printers()
@@ -53,7 +53,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_inits_cups(self, cups): def test_update_printers_inits_cups(self, cups):
""" It should init CUPS connection """ """It should init CUPS connection"""
self.new_printer() self.new_printer()
self.Model.update_printers() self.Model.update_printers()
cups.Connection.assert_called_once_with( cups.Connection.assert_called_once_with(
@@ -62,21 +62,21 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_gets_all_printers(self, cups): def test_update_printers_gets_all_printers(self, cups):
""" It should get all printers from CUPS server """ """It should get all printers from CUPS server"""
self.new_printer() self.new_printer()
self.Model.update_printers() self.Model.update_printers()
cups.Connection().getPrinters.assert_called_once_with() cups.Connection().getPrinters.assert_called_once_with()
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_search(self, cups): def test_update_printers_search(self, cups):
""" It should search all when no domain """ """It should search all when no domain"""
with mock.patch("%s.search" % model_base) as search: with mock.patch("%s.search" % model_base) as search:
self.Model.update_printers() self.Model.update_printers()
search.assert_called_once_with([]) search.assert_called_once_with([])
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_search_domain(self, cups): def test_update_printers_search_domain(self, cups):
""" It should use specific domain for search """ """It should use specific domain for search"""
with mock.patch("%s.search" % model_base) as search: with mock.patch("%s.search" % model_base) as search:
expect = [("id", ">", 0)] expect = [("id", ">", 0)]
self.Model.update_printers(expect) self.Model.update_printers(expect)
@@ -84,7 +84,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_printers_update_unavailable(self, cups): def test_update_printers_update_unavailable(self, cups):
""" It should update status when printer is unavailable """ """It should update status when printer is unavailable"""
rec_id = self.new_printer() rec_id = self.new_printer()
cups.Connection().getPrinters().get.return_value = False cups.Connection().getPrinters().get.return_value = False
self.Model.action_update_printers() self.Model.action_update_printers()
@@ -92,7 +92,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_archived_printers(self, cups): def test_update_archived_printers(self, cups):
""" It should update status even if printer is archived """ """It should update status even if printer is archived"""
rec_id = self.new_printer() rec_id = self.new_printer()
rec_id.toggle_active() rec_id.toggle_active()
self.server.refresh() self.server.refresh()
@@ -105,7 +105,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_jobs_cron(self, cups): def test_update_jobs_cron(self, cups):
""" It should get all jobs from CUPS server """ """It should get all jobs from CUPS server"""
self.new_printer() self.new_printer()
self.Model.action_update_jobs() self.Model.action_update_jobs()
cups.Connection().getPrinters.assert_called_once_with() cups.Connection().getPrinters.assert_called_once_with()
@@ -127,7 +127,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_jobs_button(self, cups): def test_update_jobs_button(self, cups):
""" It should get all jobs from CUPS server """ """It should get all jobs from CUPS server"""
self.new_printer() self.new_printer()
self.server.action_update_jobs() self.server.action_update_jobs()
cups.Connection().getPrinters.assert_called_once_with() cups.Connection().getPrinters.assert_called_once_with()
@@ -149,7 +149,7 @@ class TestPrintingServer(TransactionCase):
@mock.patch("%s.cups" % model) @mock.patch("%s.cups" % model)
def test_update_jobs_error(self, cups): def test_update_jobs_error(self, cups):
""" It should catch any exception from CUPS and update status """ """It should catch any exception from CUPS and update status"""
cups.Connection.side_effect = Exception cups.Connection.side_effect = Exception
self.new_printer() self.new_printer()
self.server.update_jobs() self.server.update_jobs()

View File

@@ -34,7 +34,7 @@ class TestPrintingTray(TransactionCase):
return self.env["printing.tray"].create(self.tray_vals) return self.env["printing.tray"].create(self.tray_vals)
def test_report_behaviour(self): def test_report_behaviour(self):
""" It should add the selected tray in the report data """ """It should add the selected tray in the report data"""
ir_report = self.env["ir.actions.report"].search([], limit=1) ir_report = self.env["ir.actions.report"].search([], limit=1)
report = self.env["printing.report.xml.action"].create( report = self.env["printing.report.xml.action"].create(
{"user_id": self.env.user.id, "report_id": ir_report.id, "action": "server"} {"user_id": self.env.user.id, "report_id": ir_report.id, "action": "server"}

View File

@@ -66,18 +66,18 @@ class TestReport(common.HttpCase):
) )
def test_can_print_report_context_skip(self): def test_can_print_report_context_skip(self):
""" It should return False based on context """ """It should return False based on context"""
rec_id = self.new_record().with_context(must_skip_send_to_printer=True) rec_id = self.new_record().with_context(must_skip_send_to_printer=True)
res = rec_id._can_print_report({"action": "server"}, True, True) res = rec_id._can_print_report({"action": "server"}, True, True)
self.assertFalse(res) self.assertFalse(res)
def test_can_print_report_true(self): def test_can_print_report_true(self):
""" It should return True when server print allowed """ """It should return True when server print allowed"""
res = self.new_record()._can_print_report({"action": "server"}, True, True) res = self.new_record()._can_print_report({"action": "server"}, True, True)
self.assertTrue(res) self.assertTrue(res)
def test_can_print_report_false(self): def test_can_print_report_false(self):
""" It should return False when server print not allowed """ """It should return False when server print not allowed"""
res = self.new_record()._can_print_report({"action": "server"}, True, False) res = self.new_record()._can_print_report({"action": "server"}, True, False)
self.assertFalse(res) self.assertFalse(res)
@@ -110,7 +110,7 @@ class TestReport(common.HttpCase):
) )
def test_print_document_not_printable(self): def test_print_document_not_printable(self):
""" It should print the report, regardless of the defined behaviour """ """It should print the report, regardless of the defined behaviour"""
self.report.printing_printer_id = self.new_printer() self.report.printing_printer_id = self.new_printer()
with mock.patch( with mock.patch(
"odoo.addons.base_report_to_printer.models." "odoo.addons.base_report_to_printer.models."
@@ -121,7 +121,7 @@ class TestReport(common.HttpCase):
print_document.assert_called_once() print_document.assert_called_once()
def test_print_document_printable(self): def test_print_document_printable(self):
""" It should print the report, regardless of the defined behaviour """ """It should print the report, regardless of the defined behaviour"""
self.report.property_printing_action_id.action_type = "server" self.report.property_printing_action_id.action_type = "server"
self.report.printing_printer_id = self.new_printer() self.report.printing_printer_id = self.new_printer()
with mock.patch( with mock.patch(
@@ -133,6 +133,6 @@ class TestReport(common.HttpCase):
print_document.assert_called_once() print_document.assert_called_once()
def test_print_document_no_printer(self): def test_print_document_no_printer(self):
""" It should raise an error """ """It should raise an error"""
with self.assertRaises(exceptions.UserError): with self.assertRaises(exceptions.UserError):
self.report.print_document(self.partners.ids) self.report.print_document(self.partners.ids)

View File

@@ -13,13 +13,13 @@ class TestResUsers(common.TransactionCase):
return self.env["res.users"].create(self.user_vals) return self.env["res.users"].create(self.user_vals)
def test_available_action_types_excludes_user_default(self): def test_available_action_types_excludes_user_default(self):
""" It should not contain `user_default` in avail actions """ """It should not contain `user_default` in avail actions"""
self.user_vals["printing_action"] = "user_default" self.user_vals["printing_action"] = "user_default"
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
self.new_record() self.new_record()
def test_available_action_types_includes_something_else(self): def test_available_action_types_includes_something_else(self):
""" It should still contain other valid keys """ """It should still contain other valid keys"""
self.user_vals["printing_action"] = "server" self.user_vals["printing_action"] = "server"
self.assertTrue(self.new_record()) self.assertTrue(self.new_record())