def test_build_node_statistics(self): stats = sb.build_node_statistics(self.test_nodes, TEST_IMAGES) # Make sure the stats match the node inputs above. self.assertEqual(13, stats['total']) self.assertEqual(4, stats['provisioned']) self.assertEqual(9, stats['not provisioned']) self.assertEqual(2, stats['available (not cached)']) self.assertEqual(7, stats['cached (includes \'caching\')']) self.assertEqual(3, stats['images']['Ubuntu']) self.assertEqual(2, stats['images']['CentOS']) self.assertEqual(1, stats['images']['CoreOS']) EXPECTED_STATS_KEYS = ( 'provisioned', 'not provisioned', 'available (not cached)', 'cached (includes \'caching\')', 'total', 'images' ) # Do some sanity checks on keys present. self.assertItemsEqual(EXPECTED_STATS_KEYS, stats.keys()) # Images with non-zero counts. Includes the unrecognized UUID. EXPECTED_IMAGE_NAMES = ['Ubuntu', 'CentOS', 'CoreOS', 'wasd'] self.assertItemsEqual(EXPECTED_IMAGE_NAMES, stats['images'].keys()) @mock.patch.object(sb.LOG, 'info') def test_log_node_statistics(self, info_log_mock): stats = sb.build_node_statistics(self.test_nodes, TEST_IMAGES) sb.log_node_statistics(stats) self.assertTrue(info_log_mock.called)
def test_build_node_statistics(self): stats = sb.build_node_statistics(self.test_nodes, TEST_IMAGES) # Make sure the stats match the node inputs above. self.assertEqual(13, stats["total"]) self.assertEqual(4, stats["provisioned"]) self.assertEqual(9, stats["not provisioned"]) self.assertEqual(2, stats["available (not cached)"]) self.assertEqual(7, stats["cached (includes 'caching')"]) self.assertEqual(3, stats["images"]["Ubuntu"]) self.assertEqual(2, stats["images"]["CentOS"]) self.assertEqual(1, stats["images"]["CoreOS"]) EXPECTED_STATS_KEYS = ( "provisioned", "not provisioned", "available (not cached)", "cached (includes 'caching')", "total", "images", ) # Do some sanity checks on keys present. self.assertItemsEqual(EXPECTED_STATS_KEYS, stats.keys()) # Images with non-zero counts. Includes the unrecognized UUID. EXPECTED_IMAGE_NAMES = ["Ubuntu", "CentOS", "CoreOS", "wasd"] self.assertItemsEqual(EXPECTED_IMAGE_NAMES, stats["images"].keys()) @mock.patch.object(sb.LOG, "info") def test_log_node_statistics(self, info_log_mock): stats = sb.build_node_statistics(self.test_nodes, TEST_IMAGES) sb.log_node_statistics(stats) self.assertTrue(info_log_mock.called)
def test_log_node_statistics(self, info_log_mock): stats = sb.build_node_statistics(self.test_nodes, TEST_IMAGES) sb.log_node_statistics(stats) self.assertTrue(info_log_mock.called)