def test_aggregate_create_in_db_with_metadata(self): fake_create_aggregate = { 'name': 'fake-aggregate', } agg = aggregate_obj._aggregate_create_in_db( self.context, fake_create_aggregate, metadata={'goodkey': 'good'}) result = aggregate_obj._aggregate_get_from_db(self.context, agg.id) md = aggregate_obj._get_by_metadata_from_db(self.context, key='goodkey') self.assertEqual(len(md), 1) self.assertEqual(md[0]['id'], agg.id) self.assertEqual(result.name, fake_create_aggregate['name'])
def test_aggregate_get_by_metadata_key_from_db(self): _create_aggregate(self.context, values={'name': 'aggregate_1'}, metadata={'goodkey': 'good'}) _create_aggregate(self.context, values={'name': 'aggregate_2'}, metadata={'goodkey': 'bad'}) _create_aggregate(self.context, values={'name': 'aggregate_3'}, metadata={'badkey': 'good'}) rl1 = aggregate_obj._get_by_metadata_from_db(self.context, key='goodkey') self.assertEqual(2, len(rl1))
def test_aggregate_get_by_metadata_key_from_db(self): _create_aggregate(self.context, values={'name': 'aggregate_1'}, metadata={'goodkey': 'good'}) _create_aggregate(self.context, values={'name': 'aggregate_2'}, metadata={'goodkey': 'bad'}) _create_aggregate(self.context, values={'name': 'aggregate_3'}, metadata={'badkey': 'good'}) rl1 = aggregate_obj._get_by_metadata_from_db(self.context, key='goodkey') self.assertEqual(2, len(rl1))
def test_aggregate_create_in_db_with_metadata(self): fake_create_aggregate = { 'name': 'fake-aggregate', } agg = aggregate_obj._aggregate_create_in_db(self.context, fake_create_aggregate, metadata={'goodkey': 'good'}) result = aggregate_obj._aggregate_get_from_db(self.context, agg.id) md = aggregate_obj._get_by_metadata_from_db(self.context, key='goodkey') self.assertEqual(len(md), 1) self.assertEqual(md[0]['id'], agg.id) self.assertEqual(result.name, fake_create_aggregate['name'])