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, {})
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)
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'})
def _create_service(self): service_info = {'host': "abc", 'binary': 'smaug-operationengine'} service = objects.Service(self.context, **service_info) service.create() return service