printer_tray: Fix mocking in unit tests (#97)

The mocking was bad, and this bug has been revealed by the usage of mock 2.0.0

OCA Transbot updated translations from Transifex
This commit is contained in:
Sylvain Garancher
2017-07-12 23:47:23 +02:00
committed by Graeme Gellatly
parent 6f08d95f00
commit d592c4e05d
2 changed files with 32 additions and 27 deletions

View File

@@ -4,13 +4,14 @@
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# Bole <bole@dajmi5.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-24 02:40+0000\n"
"PO-Revision-Date: 2017-04-24 02:40+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n"
"POT-Creation-Date: 2017-07-12 21:51+0000\n"
"PO-Revision-Date: 2017-07-12 21:51+0000\n"
"Last-Translator: Bole <bole@dajmi5.com>, 2017\n"
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -31,7 +32,7 @@ msgstr "Kreirano"
#. module: printer_tray
#: model:ir.model.fields,field_description:printer_tray.field_res_users_printer_tray_id
msgid "Default Printer Paper Source"
msgstr ""
msgstr "Zadani izvor papria na printeru"
#. module: printer_tray
#: model:ir.model.fields,field_description:printer_tray.field_printing_tray_display_name
@@ -61,51 +62,51 @@ msgstr "Zadnje ažuriranje"
#. module: printer_tray
#: model:ir.model.fields,field_description:printer_tray.field_printing_tray_name
msgid "Name"
msgstr ""
msgstr "Naziv"
#. module: printer_tray
#: model:ir.model.fields,field_description:printer_tray.field_ir_act_report_xml_printer_tray_id
#: model:ir.model.fields,field_description:printer_tray.field_printing_report_xml_action_printer_tray_id
msgid "Paper Source"
msgstr ""
msgstr "Izvor papira"
#. module: printer_tray
#: model:ir.model.fields,field_description:printer_tray.field_printing_printer_tray_ids
msgid "Paper Sources"
msgstr ""
msgstr "Izvori papira"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_printing_printer
#: model:ir.model.fields,field_description:printer_tray.field_printing_tray_printer_id
msgid "Printer"
msgstr ""
msgstr "Pisač"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_printing_tray
msgid "Printer Tray"
msgstr ""
msgstr "Ladica pisača"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_printing_report_xml_action
msgid "Printing Report Printing Actions"
msgstr ""
msgstr "Akcije ispisa izvještaja na pisač"
#. module: printer_tray
#: model:ir.model.fields,field_description:printer_tray.field_printing_tray_system_name
msgid "System name"
msgstr ""
msgstr "Sistemski naziv"
#. module: printer_tray
#: model:ir.ui.view,arch_db:printer_tray.printing_printer_view_form
msgid "Trays"
msgstr ""
msgstr "Ladice"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_res_users
msgid "Users"
msgstr ""
msgstr "Korisnici"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_ir_actions_report_xml
msgid "ir.actions.report.xml"
msgstr ""
msgstr "ir.actions.report.xml"

View File

@@ -93,6 +93,12 @@ class TestPrintingPrinter(TransactionCase):
fp.write(ppd_contents)
cups.Connection().getPPD3.return_value = (200, 0, file_name)
cups.Connection().getPrinters.return_value = {
self.printer.system_name: {
'printer-info': 'info',
'printer-uri-supported': 'uri',
},
}
def test_print_options(self):
"""
@@ -169,11 +175,9 @@ class TestPrintingPrinter(TransactionCase):
"""
self.mock_cups_ppd(cups, file_name=False)
with mock.patch.object(
self.Model, '_prepare_update_from_cups'
) as prepare_update_from_cups:
self.ServerModel.update_printers()
prepare_update_from_cups.assert_called_once()
self.assertEqual(self.printer.name, 'Printer')
self.ServerModel.update_printers()
self.assertEqual(self.printer.name, 'info')
@mock.patch('%s.cups' % server_model)
def test_prepare_update_from_cups_no_ppd(self, cups):
@@ -183,7 +187,7 @@ class TestPrintingPrinter(TransactionCase):
self.mock_cups_ppd(cups, file_name=False)
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertFalse('tray_ids' in vals)
@@ -201,7 +205,7 @@ class TestPrintingPrinter(TransactionCase):
fp.write(ppd_header)
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertFalse('tray_ids' in vals)
@@ -218,7 +222,7 @@ class TestPrintingPrinter(TransactionCase):
self.mock_cups_ppd(cups)
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
with self.assertRaises(OSError):
self.printer._prepare_update_from_cups(connection, cups_printer)
@@ -239,7 +243,7 @@ class TestPrintingPrinter(TransactionCase):
self.mock_cups_ppd(cups)
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertEqual(vals['tray_ids'], [(0, 0, {
@@ -255,7 +259,7 @@ class TestPrintingPrinter(TransactionCase):
self.mock_cups_ppd(cups)
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertEqual(vals['tray_ids'], [(0, 0, {
@@ -273,7 +277,7 @@ class TestPrintingPrinter(TransactionCase):
])
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
vals = self.printer._prepare_update_from_cups(connection, cups_printer)
self.assertEqual(vals['tray_ids'], [(0, 0, {
@@ -295,7 +299,7 @@ class TestPrintingPrinter(TransactionCase):
])
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
# Create a tray which is in the PPD file
self.new_tray({'system_name': 'Tray1'})
@@ -314,7 +318,7 @@ class TestPrintingPrinter(TransactionCase):
self.mock_cups_ppd(cups)
connection = cups.Connection()
cups_printer = connection.getPrinters()
cups_printer = connection.getPrinters()[self.printer.system_name]
# Create a tray which is absent from the PPD file
tray = self.new_tray()