mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[8.0] printer_tray: Add unit tests (#64)
* [ADD] printer_tray: Add unit tests * [FIX] Fixed lint errors
This commit is contained in:
committed by
Dave Lasley
parent
f967f952ff
commit
2cbffa75b8
50
printer_tray/tests/test_printing_tray.py
Normal file
50
printer_tray/tests/test_printing_tray.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openerp.tests.common import TransactionCase
|
||||
|
||||
|
||||
model = 'openerp.addons.base_report_to_printer.printing'
|
||||
|
||||
|
||||
class TestPrintingTray(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPrintingTray, self).setUp()
|
||||
self.Model = self.env['printing.tray']
|
||||
self.printer = self.env['printing.printer'].create({
|
||||
'name': 'Printer',
|
||||
'system_name': 'Sys Name',
|
||||
'default': True,
|
||||
'status': 'unknown',
|
||||
'status_message': 'Msg',
|
||||
'model': 'res.users',
|
||||
'location': 'Location',
|
||||
'uri': 'URI',
|
||||
})
|
||||
self.tray_vals = {
|
||||
'name': 'Tray',
|
||||
'system_name': 'TrayName',
|
||||
'printer_id': self.printer.id,
|
||||
}
|
||||
|
||||
def new_tray(self):
|
||||
return self.env['printing.tray'].create(self.tray_vals)
|
||||
|
||||
def test_report_behaviour(self):
|
||||
""" It should add the selected tray in the report data """
|
||||
ir_report = self.env['ir.actions.report.xml'].search([], limit=1)
|
||||
report = self.env['printing.report.xml.action'].create({
|
||||
'user_id': self.env.user.id,
|
||||
'report_id': ir_report.id,
|
||||
'action': 'server',
|
||||
})
|
||||
report.printer_tray_id = False
|
||||
behaviour = report.behaviour()
|
||||
self.assertEqual(behaviour['tray'], False)
|
||||
|
||||
# Check that we have te right value
|
||||
report.printer_tray_id = self.new_tray()
|
||||
behaviour = report.behaviour()
|
||||
self.assertEqual(behaviour['tray'], report.printer_tray_id.system_name)
|
||||
Reference in New Issue
Block a user