def test_networks_have_all_keys(self): nics = (FakeNic(name='vnet0', model='virtio', mac_addr='00:1a:4a:16:01:51'), ) vm = FakeVM(nics=nics) stats = {} vmstats.networks(vm, stats, self.bulk_stats, self.bulk_stats, self.interval) self.assertRepeatedStatsHaveKeys(nics, stats['network'])
def test_networks_have_all_keys(self): nics = ( FakeNic(name='vnet0', model='virtio', mac_addr='00:1a:4a:16:01:51'), ) vm = FakeVM(nics=nics) stats = {} vmstats.networks(vm, stats, self.bulk_stats, self.bulk_stats, self.interval) self.assertRepeatedStatsHaveKeys(nics, stats['network'])
def test_networks_good_interval(self): nics = (FakeNic(name='vnet0', model='virtio', mac_addr='00:1a:4a:16:01:51'), ) vm = FakeVM(nics=nics) stats = {} self.assertTrue( vmstats.networks(vm, stats, self.bulk_stats, self.bulk_stats, 1))
def test_networks_bad_interval(self, interval): nics = ( FakeNic(name='vnet0', model='virtio', mac_addr='00:1a:4a:16:01:51'), ) vm = FakeVM(nics=nics) stats = {} self.assertTrue( vmstats.networks(vm, stats, self.bulk_stats, self.bulk_stats, 0) is None )
def test_networks_missing_key(self, key): nics = ( FakeNic(name='vnet0', model='virtio', mac_addr='00:1a:4a:16:01:51'), ) vm = FakeVM(nics=nics) vm.migrationPending = True faulty_bulk_stats = {} faulty_bulk_stats.update(self.bulk_stats) del faulty_bulk_stats[key] stats = {} self.assertTrue( vmstats.networks(vm, stats, self.bulk_stats, faulty_bulk_stats, 1) )