def test_aggregate_get_by_host_with_key_from_db(self): ah1 = _create_aggregate_with_hosts(self.context, values={'name': 'fake_aggregate_1'}, metadata={'goodkey': 'good'}, hosts=['host.1.openstack.org']) _create_aggregate_with_hosts(self.context, values={'name': 'fake_aggregate_2'}, hosts=['host.1.openstack.org']) rh1 = aggregate._get_by_host_from_db(self.context, 'host.1.openstack.org', key='goodkey') self.assertEqual(1, len(rh1)) self.assertEqual(ah1['id'], rh1[0]['id'])
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))