def test_open_service_with_invalid_name(self, session): service = Service(b"\x00 a service".decode('utf-8'), session) service.open() with pytest.raises(SCMRException) as exc: service.stop() service.close() assert str(exc.value) == "Exception calling ROpenServiceW. " \ "Code: 123, Msg: ERROR_INVALID_NAME"
def test_open_service_missing(self, session): service = Service("missing-service", session) service.open() assert service._handle is None with pytest.raises(PypsexecException) as exc: service.start() assert str(exc.value) == "Cannot start service missing-service as " \ "it does not exist" with pytest.raises(PypsexecException) as exc: service.stop() assert str(exc.value) == "Cannot stop service missing-service as " \ "it does not exist" service.close()