Package x2go :: Package tests :: Module test_printing
[frames] | no frames]

Source Code for Module x2go.tests.test_printing

  1  # -*- coding: utf-8 -*- 
  2   
  3  # Copyright (C) 2010 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de> 
  4  #  
  5  # Python X2go is free software; you can redistribute it and/or modify 
  6  # it under the terms of the GNU General Public License as published by 
  7  # the Free Software Foundation; either version 3 of the License, or 
  8  # (at your option) any later version. 
  9  # 
 10  # Python X2go is distributed in the hope that it will be useful, 
 11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 13  # GNU General Public License for more details. 
 14  # 
 15  # You should have received a copy of the GNU General Public License 
 16  # along with this program; if not, write to the 
 17  # Free Software Foundation, Inc., 
 18  # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 
 19   
 20  import sys 
 21  import unittest 
 22  import tempfile 
 23  import time 
 24   
 25  # Python X2go modules 
 26  import x2go 
 27   
28 -class TestX2goClientPrinting(unittest.TestCase):
29
31 _printing = """\ 32 [General] 33 pdfview=true 34 showdialog=true 35 [print] 36 startcmd=false 37 command=lpr 38 [view] 39 open=true 40 command=xpdf 41 [CUPS] 42 defaultprinter=PDF 43 """ 44 tf = tempfile.NamedTemporaryFile() 45 print >> tf, _printing 46 tf.seek(0) 47 p_action = x2go.backends.printing.X2goClientPrinting(config_files=tf.name, client_instance='DUMMY') 48 self.assertEqual(type(p_action.print_action), x2go.printactions.X2goPrintActionDIALOG) 49 tf.close()
50
52 _printing = """\ 53 [General] 54 pdfview=true 55 [print] 56 startcmd=false 57 command=lpr 58 [view] 59 open=true 60 command=xpdf 61 [CUPS] 62 defaultprinter=PDF 63 """ 64 tf = tempfile.NamedTemporaryFile() 65 print >> tf, _printing 66 tf.seek(0) 67 p_action = x2go.backends.printing.X2goClientPrinting(config_files=tf.name) 68 self.assertEqual(type(p_action.print_action), x2go.printactions.X2goPrintActionPDFVIEW) 69 tf.close()
70
72 _printing = """\ 73 [General] 74 pdfview=true 75 [print] 76 startcmd=false 77 command=lpr 78 [view] 79 open=false 80 command=xpdf 81 [CUPS] 82 defaultprinter=PDF 83 """ 84 tf = tempfile.NamedTemporaryFile() 85 print >> tf, _printing 86 tf.seek(0) 87 p_action = x2go.backends.printing.X2goClientPrinting(config_files=tf.name) 88 self.assertEqual(type(p_action.print_action), x2go.printactions.X2goPrintActionPDFSAVE) 89 tf.close()
90
92 _printing = """\ 93 [General] 94 pdfview=false 95 [print] 96 startcmd=false 97 command=lpr 98 [view] 99 open=false 100 command=xpdf 101 [CUPS] 102 defaultprinter=PDF 103 """ 104 tf = tempfile.NamedTemporaryFile() 105 print >> tf, _printing 106 tf.seek(0) 107 p_action = x2go.backends.printing.X2goClientPrinting(config_files=tf.name) 108 self.assertEqual(type(p_action.print_action), x2go.printactions.X2goPrintActionPRINT) 109 tf.close()
110
112 _printing = """\ 113 [General] 114 pdfview=false 115 [print] 116 startcmd=true 117 command=lpr 118 [view] 119 open=false 120 command=xpdf 121 [CUPS] 122 defaultprinter=PDF 123 """ 124 tf = tempfile.NamedTemporaryFile() 125 print >> tf, _printing 126 tf.seek(0) 127 p_action = x2go.backends.printing.X2goClientPrinting(config_files=tf.name) 128 self.assertEqual(type(p_action.print_action), x2go.printactions.X2goPrintActionPRINTCMD) 129 tf.close()
130
131 -def test_suite():
132 from unittest import TestSuite, makeSuite 133 suite = TestSuite() 134 suite.addTest(makeSuite(TestX2goClientPrinting)) 135 return suite
136