Exemplo n.º 1
0
  def test_get(self):
    resource_stamp = time() + 100
    value = ResourceMonitorBase.ResourceResult(1, 1, 0)
    value_wrong = ResourceMonitorBase.ResourceResult(1, 1, 50)

    self.resource_history.add(resource_stamp, value)
    self.resource_history.add(resource_stamp + 1000, value_wrong)
    self.resource_history.add(resource_stamp + 10000, value_wrong)
    assert resource_stamp, value == self.resource_history.get(resource_stamp)
Exemplo n.º 2
0
  def test_add(self):
    next_resource_stamp = time() + 100
    value = ResourceMonitorBase.ResourceResult(1, 1, 0)

    assert (next_resource_stamp, value) not in self.resource_history._values
    self.resource_history.add(next_resource_stamp, value)
    assert (next_resource_stamp, value) == self.resource_history._values[1]
Exemplo n.º 3
0
def _mock_resource_monitor(num_procs=0, process_sample=ProcessSample.empty(), disk_usage=0):
  mock_resource_monitor = mock.Mock(spec=ResourceMonitorBase)
  mock_resource_monitor.sample.return_value = (
      12345,  # timestamp
      ResourceMonitorBase.ResourceResult(num_procs, process_sample, disk_usage))

  return mock_resource_monitor