~elachuni/software-center/pep8-test-part18

« back to all changes in this revision

Viewing changes to test/test_hw.py

  • Committer: Gary Lasker
  • Date: 2012-03-15 21:03:55 UTC
  • mfrom: (2863.2.5 opengl-driver)
  • Revision ID: gary.lasker@canonical.com-20120315210355-ln60xsck4fm4x5g4
* lp:~mvo/software-center/opengl-driver-blacklist:
  - add support for video driver blacklisting

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import unittest
 
4
 
 
5
from mock import patch
 
6
 
 
7
from testutils import setup_test_env
 
8
setup_test_env()
 
9
from softwarecenter.hw import (
 
10
    get_hardware_support_for_tags, 
 
11
    get_hw_missing_long_description,
 
12
    OPENGL_DRIVER_BLACKLIST_TAG)
 
13
 
 
14
class TestHW(unittest.TestCase):
 
15
    """ tests the hardware support detection """
 
16
 
 
17
    def test_get_hardware_support_for_tags(self):
 
18
        tags = [OPENGL_DRIVER_BLACKLIST_TAG + "intel",
 
19
                "hardware::input:mouse",
 
20
               ]
 
21
        with patch("debtagshw.opengl.get_driver") as mock_get_driver:
 
22
            # test with the intel driver
 
23
            mock_get_driver.return_value = "intel"
 
24
            supported = get_hardware_support_for_tags(tags)
 
25
            self.assertEqual(supported[tags[0]], "no")
 
26
            self.assertEqual(len(supported), 2)
 
27
            # now with fake amd driver
 
28
            mock_get_driver.return_value = "amd"
 
29
            supported = get_hardware_support_for_tags(tags)
 
30
            self.assertEqual(supported[tags[0]], "yes")
 
31
 
 
32
    def test_get_hw_missing_long_description(self):
 
33
        s = get_hw_missing_long_description(
 
34
            { "hardware::input:keyboard": "yes",
 
35
              OPENGL_DRIVER_BLACKLIST_TAG + "intel": "no",
 
36
            })
 
37
        self.assertEqual(s, 'This computer uses a "intel" video driver, '
 
38
                         'but the application is not compatible with that.')
 
39
 
 
40
 
 
41
if __name__ == "__main__":
 
42
    #import logging
 
43
    #logging.basicConfig(level=logging.DEBUG)
 
44
    unittest.main()