| 1 |
|
| 2 |
|
| 3 |
import unittest |
| 4 |
from cpuinfo import * |
| 5 |
import helpers |
| 6 |
|
| 7 |
|
| 8 |
class MockDataSource: |
| 9 |
bits = '64bit' |
| 10 |
cpu_count = 1 |
| 11 |
is_windows = False |
| 12 |
arch_string_raw = 'x86_64' |
| 13 |
uname_string_raw = 'x86_64' |
| 14 |
|
| 15 |
@staticmethod |
| 16 |
def has_proc_cpuinfo(): |
| 17 |
return False |
| 18 |
|
| 19 |
@staticmethod |
| 20 |
def has_dmesg(): |
| 21 |
return False |
| 22 |
|
| 23 |
@staticmethod |
| 24 |
def has_var_run_dmesg_boot(): |
| 25 |
return False |
| 26 |
|
| 27 |
@staticmethod |
| 28 |
def has_cpufreq_info(): |
| 29 |
return False |
| 30 |
|
| 31 |
@staticmethod |
| 32 |
def has_sestatus(): |
| 33 |
return False |
| 34 |
|
| 35 |
@staticmethod |
| 36 |
def has_sysctl(): |
| 37 |
return False |
| 38 |
|
| 39 |
@staticmethod |
| 40 |
def has_isainfo(): |
| 41 |
return False |
| 42 |
|
| 43 |
@staticmethod |
| 44 |
def has_kstat(): |
| 45 |
return False |
| 46 |
|
| 47 |
@staticmethod |
| 48 |
def has_sysinfo(): |
| 49 |
return False |
| 50 |
|
| 51 |
@staticmethod |
| 52 |
def has_lscpu(): |
| 53 |
return False |
| 54 |
|
| 55 |
@staticmethod |
| 56 |
def cat_proc_cpuinfo(): |
| 57 |
return 1, None |
| 58 |
|
| 59 |
@staticmethod |
| 60 |
def cpufreq_info(): |
| 61 |
return 1, None |
| 62 |
|
| 63 |
@staticmethod |
| 64 |
def sestatus_b(): |
| 65 |
return 1, None |
| 66 |
|
| 67 |
@staticmethod |
| 68 |
def dmesg_a(): |
| 69 |
return 1, None |
| 70 |
|
| 71 |
@staticmethod |
| 72 |
def cat_var_run_dmesg_boot(): |
| 73 |
return 1, None |
| 74 |
|
| 75 |
@staticmethod |
| 76 |
def sysctl_machdep_cpu_hw_cpufrequency(): |
| 77 |
return 1, None |
| 78 |
|
| 79 |
@staticmethod |
| 80 |
def isainfo_vb(): |
| 81 |
return 1, None |
| 82 |
|
| 83 |
@staticmethod |
| 84 |
def kstat_m_cpu_info(): |
| 85 |
return 1, None |
| 86 |
|
| 87 |
@staticmethod |
| 88 |
def lscpu(): |
| 89 |
return 1, None |
| 90 |
|
| 91 |
@staticmethod |
| 92 |
def sysinfo_cpu(): |
| 93 |
return 1, None |
| 94 |
|
| 95 |
@staticmethod |
| 96 |
def winreg_processor_brand(): |
| 97 |
return None |
| 98 |
|
| 99 |
@staticmethod |
| 100 |
def winreg_vendor_id_raw(): |
| 101 |
return None |
| 102 |
|
| 103 |
@staticmethod |
| 104 |
def winreg_arch_string_raw(): |
| 105 |
return None |
| 106 |
|
| 107 |
@staticmethod |
| 108 |
def winreg_hz_actual(): |
| 109 |
return None |
| 110 |
|
| 111 |
@staticmethod |
| 112 |
def winreg_feature_bits(): |
| 113 |
return None |
| 114 |
|
| 115 |
|
| 116 |
class TestExample(unittest.TestCase): |
| 117 |
def setUp(self): |
| 118 |
helpers.backup_data_source(cpuinfo) |
| 119 |
helpers.monkey_patch_data_source(cpuinfo, MockDataSource) |
| 120 |
|
| 121 |
def tearDown(self): |
| 122 |
helpers.restore_data_source(cpuinfo) |
| 123 |
|
| 124 |
def test_all(self): |
| 125 |
self.assertEqual({}, cpuinfo._get_cpu_info_from_registry()) |
| 126 |
|
| 127 |
self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo()) |
| 128 |
|
| 129 |
self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl()) |
| 130 |
|
| 131 |
self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat()) |
| 132 |
|
| 133 |
self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg()) |
| 134 |
|
| 135 |
self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot()) |
| 136 |
|
| 137 |
self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo()) |
| 138 |
|
| 139 |
#self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid()) |
| 140 |
|
| 141 |
#self.assertEqual({}, cpuinfo._get_cpu_info_internal()) |