diff --git a/base_report_to_printer/models/ir_actions_report.py b/base_report_to_printer/models/ir_actions_report.py index b7a7122..9ff6204 100644 --- a/base_report_to_printer/models/ir_actions_report.py +++ b/base_report_to_printer/models/ir_actions_report.py @@ -35,7 +35,7 @@ class IrActionsReport(models.Model): @api.onchange("printing_printer_id") 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 @api.model @@ -99,7 +99,7 @@ class IrActionsReport(models.Model): return result 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( must_skip_send_to_printer=True )._render_qweb_pdf(record_ids, data=data) diff --git a/base_report_to_printer/models/printing_printer.py b/base_report_to_printer/models/printing_printer.py index 5e37bad..d954acf 100644 --- a/base_report_to_printer/models/printing_printer.py +++ b/base_report_to_printer/models/printing_printer.py @@ -173,7 +173,7 @@ class PrintingPrinter(models.Model): return options def print_file(self, file_name, report=None, **print_opts): - """ Print a file """ + """Print a file""" self.ensure_one() title = print_opts.pop("title", file_name) connection = self.server_id._open_connection(raise_on_error=True) diff --git a/base_report_to_printer/models/printing_report_xml_action.py b/base_report_to_printer/models/printing_report_xml_action.py index 34a3a92..cac2a0b 100644 --- a/base_report_to_printer/models/printing_report_xml_action.py +++ b/base_report_to_printer/models/printing_report_xml_action.py @@ -35,7 +35,7 @@ class PrintingReportXmlAction(models.Model): @api.onchange("printer_id") 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 def behaviour(self): diff --git a/base_report_to_printer/models/res_users.py b/base_report_to_printer/models/res_users.py index 9ff9a49..c7e1c31 100644 --- a/base_report_to_printer/models/res_users.py +++ b/base_report_to_printer/models/res_users.py @@ -38,5 +38,5 @@ class ResUsers(models.Model): @api.onchange("printing_printer_id") 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 diff --git a/base_report_to_printer/tests/test_ir_actions_report.py b/base_report_to_printer/tests/test_ir_actions_report.py index 927fc0d..64332f9 100644 --- a/base_report_to_printer/tests/test_ir_actions_report.py +++ b/base_report_to_printer/tests/test_ir_actions_report.py @@ -54,14 +54,14 @@ class TestIrActionsReportXml(TransactionCase): return self.env["printing.tray"].create(values) 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: expect = "test" self.Model.print_action_for_report_name(expect) mk.assert_called_once_with(expect) 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: expect = "test" mk.return_value = False @@ -69,7 +69,7 @@ class TestIrActionsReportXml(TransactionCase): self.assertDictEqual({}, res) 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: res = self.Model.print_action_for_report_name("test") behaviour = mk().behaviour() @@ -80,7 +80,7 @@ class TestIrActionsReportXml(TransactionCase): self.assertDictEqual(expect, res, "Expect {}, Got {}".format(expect, res)) 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) self.env.user.printing_action = False self.env.user.printing_printer_id = False @@ -96,7 +96,7 @@ class TestIrActionsReportXml(TransactionCase): ) 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) self.env.user.printing_action = "client" self.env.user.printing_printer_id = self.new_printer() @@ -110,7 +110,7 @@ class TestIrActionsReportXml(TransactionCase): ) 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) self.env.user.printing_action = "client" report.property_printing_action_id = self.new_action() @@ -125,7 +125,7 @@ class TestIrActionsReportXml(TransactionCase): ) 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) self.env.user.printing_action = "client" report.property_printing_action_id.action_type = "user_default" @@ -180,7 +180,7 @@ class TestIrActionsReportXml(TransactionCase): ) 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) self.env.user.printing_action = "client" printing_action = self.new_printing_action() diff --git a/base_report_to_printer/tests/test_printing_job.py b/base_report_to_printer/tests/test_printing_job.py index df81201..1f5c929 100644 --- a/base_report_to_printer/tests/test_printing_job.py +++ b/base_report_to_printer/tests/test_printing_job.py @@ -44,7 +44,7 @@ class TestPrintingJob(TransactionCase): @mock.patch("%s.cups" % model) 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 printer = self.new_printer() job = self.new_job(printer, {"job_id_cups": 2}) @@ -54,7 +54,7 @@ class TestPrintingJob(TransactionCase): @mock.patch("%s.cups" % model) 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() job = self.new_job(printer) job.cancel() diff --git a/base_report_to_printer/tests/test_printing_printer.py b/base_report_to_printer/tests/test_printing_printer.py index fe78c16..6cadf02 100644 --- a/base_report_to_printer/tests/test_printing_printer.py +++ b/base_report_to_printer/tests/test_printing_printer.py @@ -64,7 +64,7 @@ class TestPrintingPrinter(TransactionCase): self.assertEqual(self.Model._set_option_format(None, "pdf"), {}) 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 # with tests in test_printing_printer_tray from when modules merged report = self.env["ir.actions.report"].search([], limit=1) @@ -81,7 +81,7 @@ class TestPrintingPrinter(TransactionCase): @mock.patch("%s.cups" % server_model) 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() with mock.patch("%s.mkstemp" % model) as mkstemp: mkstemp.return_value = fd, file_name @@ -93,7 +93,7 @@ class TestPrintingPrinter(TransactionCase): @mock.patch("%s.cups" % server_model) 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 fd, file_name = tempfile.mkstemp() with mock.patch("%s.mkstemp" % model) as mkstemp: @@ -106,7 +106,7 @@ class TestPrintingPrinter(TransactionCase): @mock.patch("%s.cups" % server_model) def test_print_file(self, cups): - """ It should print a file through CUPS """ + """It should print a file through CUPS""" file_name = "file_name" printer = self.new_record() printer.print_file(file_name, "pdf") @@ -116,7 +116,7 @@ class TestPrintingPrinter(TransactionCase): @mock.patch("%s.cups" % server_model) 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 file_name = "file_name" printer = self.new_record() @@ -124,7 +124,7 @@ class TestPrintingPrinter(TransactionCase): printer.print_file(file_name) 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() self.assertTrue(printer.default) other_printer = self.new_record() @@ -136,7 +136,7 @@ class TestPrintingPrinter(TransactionCase): self.assertEqual(other_printer, self.Model.get_default()) 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() self.assertTrue(printer.default) printer.unset_default() @@ -144,7 +144,7 @@ class TestPrintingPrinter(TransactionCase): @mock.patch("%s.cups" % server_model) def test_cancel_all_jobs(self, cups): - """ It should cancel all jobs """ + """It should cancel all jobs""" printer = self.new_record() printer.action_cancel_all_jobs() cups.Connection().cancelAllJobs.assert_called_once_with( @@ -153,7 +153,7 @@ class TestPrintingPrinter(TransactionCase): @mock.patch("%s.cups" % server_model) def test_cancel_and_purge_all_jobs(self, cups): - """ It should cancel all jobs """ + """It should cancel all jobs""" printer = self.new_record() printer.cancel_all_jobs(purge_jobs=True) cups.Connection().cancelAllJobs.assert_called_once_with( @@ -162,21 +162,21 @@ class TestPrintingPrinter(TransactionCase): @mock.patch("%s.cups" % server_model) def test_enable_printer(self, cups): - """ It should enable the printer """ + """It should enable the printer""" printer = self.new_record() printer.enable() cups.Connection().enablePrinter.assert_called_once_with(printer.system_name) @mock.patch("%s.cups" % server_model) def test_disable_printer(self, cups): - """ It should disable the printer """ + """It should disable the printer""" printer = self.new_record() printer.disable() cups.Connection().disablePrinter.assert_called_once_with(printer.system_name) @mock.patch("%s.cups" % server_model) def test_print_test_page(self, cups): - """ It should print a test page """ + """It should print a test page""" printer = self.new_record() printer.print_test_page() cups.Connection().printTestPage.assert_called_once_with(printer.system_name) diff --git a/base_report_to_printer/tests/test_printing_printer_wizard.py b/base_report_to_printer/tests/test_printing_printer_wizard.py index 0914a8b..11788c0 100644 --- a/base_report_to_printer/tests/test_printing_printer_wizard.py +++ b/base_report_to_printer/tests/test_printing_printer_wizard.py @@ -38,7 +38,7 @@ class TestPrintingPrinterWizard(TransactionCase): @mock.patch("%s.cups" % model) def test_action_ok_inits_connection(self, cups): - """ It should initialize CUPS connection """ + """It should initialize CUPS connection""" self.Model.action_ok() cups.Connection.assert_called_once_with( host=self.server.address, port=self.server.port @@ -46,7 +46,7 @@ class TestPrintingPrinterWizard(TransactionCase): @mock.patch("%s.cups" % model) 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().getPPD3.return_value = (200, 0, "") self.Model.action_ok() @@ -54,14 +54,14 @@ class TestPrintingPrinterWizard(TransactionCase): @mock.patch("%s.cups" % model) 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 with self.assertRaises(UserError): self.Model.action_ok() @mock.patch("%s.cups" % model) 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().getPPD3.return_value = (200, 0, "") self.Model.action_ok() @@ -77,7 +77,7 @@ class TestPrintingPrinterWizard(TransactionCase): @mock.patch("%s.cups" % model) 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().getPPD3.return_value = (200, 0, "") self.env["printing.printer"].create(self._record_vals()) diff --git a/base_report_to_printer/tests/test_printing_server.py b/base_report_to_printer/tests/test_printing_server.py index 324cf03..eb289f8 100644 --- a/base_report_to_printer/tests/test_printing_server.py +++ b/base_report_to_printer/tests/test_printing_server.py @@ -45,7 +45,7 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) 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 rec_id = self.new_printer() self.Model.update_printers() @@ -53,7 +53,7 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) def test_update_printers_inits_cups(self, cups): - """ It should init CUPS connection """ + """It should init CUPS connection""" self.new_printer() self.Model.update_printers() cups.Connection.assert_called_once_with( @@ -62,21 +62,21 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) 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.Model.update_printers() cups.Connection().getPrinters.assert_called_once_with() @mock.patch("%s.cups" % model) 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: self.Model.update_printers() search.assert_called_once_with([]) @mock.patch("%s.cups" % model) 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: expect = [("id", ">", 0)] self.Model.update_printers(expect) @@ -84,7 +84,7 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) 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() cups.Connection().getPrinters().get.return_value = False self.Model.action_update_printers() @@ -92,7 +92,7 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) 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.toggle_active() self.server.refresh() @@ -105,7 +105,7 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) 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.Model.action_update_jobs() cups.Connection().getPrinters.assert_called_once_with() @@ -127,7 +127,7 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) 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.server.action_update_jobs() cups.Connection().getPrinters.assert_called_once_with() @@ -149,7 +149,7 @@ class TestPrintingServer(TransactionCase): @mock.patch("%s.cups" % model) 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 self.new_printer() self.server.update_jobs() diff --git a/base_report_to_printer/tests/test_printing_tray.py b/base_report_to_printer/tests/test_printing_tray.py index 4b8739d..fed2724 100644 --- a/base_report_to_printer/tests/test_printing_tray.py +++ b/base_report_to_printer/tests/test_printing_tray.py @@ -34,7 +34,7 @@ class TestPrintingTray(TransactionCase): return self.env["printing.tray"].create(self.tray_vals) 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) report = self.env["printing.report.xml.action"].create( {"user_id": self.env.user.id, "report_id": ir_report.id, "action": "server"} diff --git a/base_report_to_printer/tests/test_report.py b/base_report_to_printer/tests/test_report.py index 23a73bc..876d5f1 100644 --- a/base_report_to_printer/tests/test_report.py +++ b/base_report_to_printer/tests/test_report.py @@ -66,18 +66,18 @@ class TestReport(common.HttpCase): ) 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) res = rec_id._can_print_report({"action": "server"}, True, True) self.assertFalse(res) 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) self.assertTrue(res) 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) self.assertFalse(res) @@ -110,7 +110,7 @@ class TestReport(common.HttpCase): ) 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() with mock.patch( "odoo.addons.base_report_to_printer.models." @@ -121,7 +121,7 @@ class TestReport(common.HttpCase): print_document.assert_called_once() 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.printing_printer_id = self.new_printer() with mock.patch( @@ -133,6 +133,6 @@ class TestReport(common.HttpCase): print_document.assert_called_once() def test_print_document_no_printer(self): - """ It should raise an error """ + """It should raise an error""" with self.assertRaises(exceptions.UserError): self.report.print_document(self.partners.ids) diff --git a/base_report_to_printer/tests/test_res_users.py b/base_report_to_printer/tests/test_res_users.py index c64bed5..6f3df48 100644 --- a/base_report_to_printer/tests/test_res_users.py +++ b/base_report_to_printer/tests/test_res_users.py @@ -13,13 +13,13 @@ class TestResUsers(common.TransactionCase): return self.env["res.users"].create(self.user_vals) 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" with self.assertRaises(ValueError): self.new_record() 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.assertTrue(self.new_record())