def get_host_cpu_mhz_exception():
     cpu_mhz = 1
     total = 1.
     prev_total = 0.
     busy = 1.
     prev_busy = 2.
     with MockTransaction:
         expect(collector).get_host_cpu_time(). \
             and_return((total, busy)).once()
         try:
             collector.get_host_cpu_mhz(cpu_mhz, prev_total, prev_busy)
             assert False
         except ValueError:
             assert True
Ejemplo n.º 2
0
 def get_host_cpu_mhz_exception():
     cpu_mhz = 1
     total = 1.
     prev_total = 0.
     busy = 1.
     prev_busy = 2.
     with MockTransaction:
         expect(collector).get_host_cpu_time(). \
             and_return((total, busy)).once()
         try:
             collector.get_host_cpu_mhz(cpu_mhz, prev_total, prev_busy)
             assert False
         except ValueError:
             assert True
Ejemplo n.º 3
0
 def get_host_cpu_mhz(cpu_mhz=int_(min=1, max=1000),
                      prev_total=float_(min=100, max=1000),
                      prev_busy=float_(min=1, max=100),
                      diff_total=float_(min=100, max=1000),
                      diff_busy=float_(min=1, max=100)):
     with MockTransaction:
         total = prev_total + diff_total
         busy = prev_busy + diff_busy
         expect(collector).get_host_cpu_time(). \
             and_return((total, busy)).once()
         assert collector.get_host_cpu_mhz(cpu_mhz, prev_total, prev_busy) == \
             (total,
              busy,
              int(cpu_mhz * diff_busy / diff_total))
 def get_host_cpu_mhz(
     cpu_mhz=int_(min=1, max=1000),
     prev_total=float_(min=100, max=1000),
     prev_busy=float_(min=1, max=100),
     diff_total=float_(min=100, max=1000),
     diff_busy=float_(min=1, max=100)
 ):
     with MockTransaction:
         total = prev_total + diff_total
         busy = prev_busy + diff_busy
         expect(collector).get_host_cpu_time(). \
             and_return((total, busy)).once()
         assert collector.get_host_cpu_mhz(cpu_mhz, prev_total, prev_busy) == \
             (total,
              busy,
              int(cpu_mhz * diff_busy / diff_total))