~ubuntu-branches/ubuntu/saucy/jockey/saucy

« back to all changes in this revision

Viewing changes to tests/detection.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2011-11-25 14:32:50 UTC
  • Revision ID: package-import@ubuntu.com-20111125143250-3420kburqqcg8iqp
Tags: 0.9.5-0ubuntu6
* Merge from trunk:
  - tests/detection.py: Make OpenPrinting.org test case robust against minor
    version changes
  - get_handlers(): Ignore handler classes which start with a "_". These can
    be used to mark private base classes and avoid error messages.
* tests/oslib.py: Fix MockPackage to have an architecture() method, now
  needed by the Apt implementation.
* data/handlers/nvidia.py: Prefix base class with '_' to avoid error
  messages and failing the "shipped_handlers" tests.
* Add debian/tests/control and debian/tests/upstream-system:
  DEP-8/autopkgtest control file for running the upstream tests against the
  installed system Jockey package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
            else:
218
218
                self.assert_(h.enabled())
219
219
 
 
220
    def test_get_handlers_private_class(self):
 
221
        '''get_handlers() ignores private base classes starting with _'''
 
222
 
 
223
        open(os.path.join(OSLib.inst.handler_dir, 'kmod_baseclass.py'), 'w').write(
 
224
            sandbox.h_privateclass_py)
 
225
 
 
226
        log_offset = sandbox.log.tell()
 
227
        h = jockey.detection.get_handlers(jockey.backend.Backend())
 
228
        log = sandbox.log.getvalue()[log_offset:]
 
229
 
 
230
        self.assertEqual(len(h), 1)
 
231
        for h in h: pass # get single item in set h
 
232
        self.assert_(isinstance(h, jockey.handlers.Handler))
 
233
        self.assert_(h.available())
 
234
        self.assertEqual(str(h.__class__).split('.')[-1], 'MyHandler')
 
235
 
 
236
        self.failIf('Could not instantiate Handler' in log, log)
 
237
 
220
238
    def test_localkernelmod_driverdb(self):
221
239
        '''LocalKernelModulesDriverDB creates appropriate handlers
222
240
        
885
903
        finally:
886
904
            OSLib.inst.packaging_system = orig_pkgsys
887
905
        handlers = backend.available()
888
 
        self.assertEqual(handlers, ['printer:epson-inkjet-printer-n10-nx127:1.0.0'])
 
906
        self.assertEqual(len(handlers), 1)
 
907
        self.assertTrue(handlers[0].startswith('printer:epson-inkjet-printer-n10-nx127:1'))
889
908
 
890
909
        hi = backend.handler_info(handlers[0])
891
910
        self.assert_(hi['package'].startswith('epson-inkjet-'))