示例#1
0
 def test_destroy(self, service_destroy):
     db_service = fake_service.fake_db_service()
     service = objects.Service._from_db_object(
         self.context, objects.Service(), db_service)
     with mock.patch.object(service._context, 'elevated') as elevated_ctx:
         service.destroy()
         service_destroy.assert_called_once_with(elevated_ctx(), 123)
示例#2
0
 def test_create(self, service_create):
     db_service = fake_service.fake_db_service()
     service_create.return_value = db_service
     service = objects.Service(context=self.context)
     service.create()
     self.assertEqual(db_service['id'], service.id)
     service_create.assert_called_once_with(self.context, {})
示例#3
0
 def test_save(self, service_update):
     db_service = fake_service.fake_db_service()
     service = objects.Service._from_db_object(
         self.context, objects.Service(), db_service)
     service.topic = 'foobar'
     service.save()
     service_update.assert_called_once_with(self.context, service.id,
                                            {'topic': 'foobar'})
示例#4
0
 def _create_service(self):
     service_info = {'host': "abc", 'binary': 'karbor-operationengine'}
     service = objects.Service(self.context, **service_info)
     service.create()
     return service