def test_empty_ish_perfdata(): provider = lambda: '' with pytest.raises(ValueError): perfdata = PerfData.get(provider) provider = lambda: PerfData.MAGIC with pytest.raises(ValueError): perfdata = PerfData.get(provider)
def test_struct_unpack_error(): provider = lambda: pkgutil.get_data('twitter.common.java', _EXAMPLE_RESOURCE) perfdata = PerfData.get(provider) assert perfdata is not None with mock.patch('struct.unpack') as struct_unpack: struct_unpack.side_effect = struct.error('My shit got corrupted!') with pytest.raises(perfdata.ParseError): perfdata.sample()
def main(args, options): if len(args) > 0: app.error('Must provide hsperfdata via -f/-p') if options.list: print_pids() return perfdata = None if options.filename: perfdata = PerfData.get(file_provider()) elif options.pid: perfdata = PerfData.get(pid_provider()) if perfdata is None: app.error('No hsperfdata provider specified!') perfdata.sample() for key in sorted(perfdata): print('%s: %s' % (key, perfdata[key]))
def test_perfdata_integration(): provider = lambda: pkgutil.get_data('twitter.common.java', _EXAMPLE_RESOURCE) perfdata = PerfData.get(provider) assert perfdata is not None perfdata.sample() assert len(perfdata) > 0 keys = set(perfdata) for key in perfdata: assert key in keys assert perfdata[key] is not None