Example #1
0
    def test_get_objects_with_string_matching_filters_contains(self):
        obj1 = api.create_object(self.ctxt, self.model, {'name': 'obj_con_1'})
        obj2 = api.create_object(self.ctxt, self.model, {'name': 'obj_con_2'})
        obj3 = api.create_object(self.ctxt, self.model, {'name': 'obj_3'})

        objs = api.get_objects(self.ctxt,
                               self.model,
                               name=obj_utils.StringContains('con'))
        self.assertEqual(2, len(objs))
        self.assertIn(obj1, objs)
        self.assertIn(obj2, objs)
        self.assertNotIn(obj3, objs)
Example #2
0
 def get_objects_by_agent_mode(cls, context, agent_mode=None, **kwargs):
     mode_filter = obj_utils.StringContains(agent_mode)
     return cls.get_objects(context, configurations=mode_filter, **kwargs)