def test_aggregate_get_by_host_from_db(self): _create_aggregate_with_hosts(self.context, values={'name': 'fake_aggregate_1'}, hosts=['host.1.openstack.org']) _create_aggregate_with_hosts(self.context, values={'name': 'fake_aggregate_2'}, hosts=['host.1.openstack.org']) _create_aggregate(self.context, values={'name': 'no_host_aggregate'}) rh1 = aggregate._get_all_from_db(self.context) rh2 = aggregate._get_by_host_from_db(self.context, 'host.1.openstack.org') self.assertEqual(3, len(rh1)) self.assertEqual(2, len(rh2))
def test_aggregate_get_all_from_db(self): for c in range(3): _create_aggregate(self.context, values={'name': 'fake_aggregate_%d' % c}) results = aggregate._get_all_from_db(self.context) self.assertEqual(len(results), 3)