~ubuntu-branches/ubuntu/vivid/debtags/vivid

« back to all changes in this revision

Viewing changes to test/test_hw.py

  • Committer: Package Import Robot
  • Author(s): Enrico Zini, Michael Vogt, Enrico Zini
  • Date: 2013-10-25 12:41:25 UTC
  • Revision ID: package-import@ubuntu.com-20131025124125-ytl4xarlmdyiuzjb
Tags: 1.12
[ Michael Vogt ]
* Install files in python3-debtagshw

[ Enrico Zini ]
* Build with new wibble

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
# along with this program; if not, write to the Free Software
22
22
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
23
 
 
24
from __future__ import absolute_import
 
25
 
24
26
import logging
25
27
import unittest
26
28
import tempfile
29
31
 
30
32
 
31
33
import sys
32
 
sys.path.insert(0, "../")
33
34
 
34
35
from debtagshw.detectors import (
35
36
    Detector,
61
62
        # this may fail on a buildd with no keyboard
62
63
        hw = DebtagsAvailableHW()
63
64
        self.assertTrue(hw._check_hw_debtag("hardware::input:keyboard"))
64
 
    
 
65
 
65
66
    def test_laptop_detect(self):
66
67
        d = DetectorCmdline()
67
68
        d.LAPTOP_DETECT = "/bin/true"
73
74
 
74
75
    def test_scanner(self):
75
76
        f = tempfile.NamedTemporaryFile()
76
 
        f.write("device 'uri' is a foo bar bar")
 
77
        test_bytes = "device 'uri' is a foo bar bar"
 
78
        if sys.version > '3':
 
79
            test_bytes = test_bytes.encode()
 
80
        f.write(test_bytes)
77
81
        f.flush()
78
82
        d = DetectorCmdline()
79
83
        d.SCANIMAGE = ["cat", f.name]
112
116
            'hardware::gps' : HardwareSupported.NO,
113
117
            'hardware::xxx' : HardwareSupported.UNKNOWN,
114
118
            })
115
 
        
 
119
 
116
120
    def test_generate_tag_expressions(self):
117
121
        res = {}
118
122
        # test
126
130
 
127
131
    def _make_cups_mock(self):
128
132
        import cups
129
 
        cups_mock = Mock()        
 
133
        cups_mock = Mock()
130
134
        cups_connection_mock = Mock(cups.Connection)
131
135
        cups_mock.Connection.return_value = cups_connection_mock
132
136
        return cups_mock, cups_connection_mock
138
142
            cups_connection_mock.getPrinters.return_value = {}
139
143
            self.assertEqual(hw._check_hw_debtag("hardware::printer"),
140
144
                             HardwareSupported.NO)
141
 
            cups_connection_mock.getPrinters.return_value = { 
 
145
            cups_connection_mock.getPrinters.return_value = {
142
146
                'deskjet' : { 'print-info' : "some info",
143
147
                            },
144
148
                }
184
188
                if driver != "unknown":
185
189
                    opengl_version = detector.opengl_version()
186
190
                    self.assertNotEqual(opengl_version, "unknown")
187
 
                    
 
191
 
188
192
 
189
193
if __name__ == "__main__":
190
194
    logging.basicConfig(level=logging.INFO)