Cli-microsoft365: New command: get information about the specified list

Created on 1 Jan 2018  路  12Comments  路  Source: pnp/cli-microsoft365

Get information about the specified list

  • command: spo list get -u|--webUrl <webUrl> -i|--id [id] -t|--title [title]
  • webUrl: URL of the site where the list to retrieve is located
  • id: List id
  • title: List title
  • specify either id or title but not both

Retrieve list using GET <webUrl>/_api/web/lists(guid'<id>') or GET <webUrl>/_api/web/lists/GetByTitle('<title>'). Ensure you have access token for the specified web.

good first issue new feature work in progress

All 12 comments

As requested: all yours @rfjschouten 馃挭

@waldekmastykarz I published my branch to my forked project. The command is implemented and works. I only have one test which is failing at the moment and I don't see what's the problem. Could you take a look?
https://github.com/rfjschouten/office365-cli/tree/getlistinformation

Hey @rfjschouten , I checked the issue and it is related to sinon.
TypeError: Attempted to wrap ensureAccessToken which is already wrapped.

Basically when you create sinon spy or sinon stub wrapper on a function/method, you have to restore it or remove that wrapper so the same function/method can be wrapped in other command tests suit.

In your case you are wrapping

 before(() => {
   ...
    sinon.stub(auth, 'ensureAccessToken').callsFake(() => { return Promise.resolve('ABC'); });
    ...
  });

but that ensureAccessToken has never been restored so the next tests suite fails.

Here is what you have to do to fix it. Change:

  after(() => {
    Utils.restore([
      appInsights.trackEvent,
      auth.getAccessToken,
      auth.restoreAuth,
      request.get
    ]);
  });

to

  after(() => {
    Utils.restore([
      appInsights.trackEvent,
      auth.ensureAccessToken,
      auth.restoreAuth,
      request.get
    ]);
  });

That should restore (release) the method and let other test suits to create wrapper around it.

Hi @VelinGeorgiev thanks for taking a look at the code. Your change is resolving the problem indeed where the next test was failing due to sinon. I still have 1 test which is failing on an assert which I don't see why it is failing:

1) spo list get
retrieves and prints all details user custom actions if title option is passed:

  AssertionError [ERR_ASSERTION]: false == true
  + expected - actual

  -false
  +true

On another note @rfjschouten, I had a quick look at your code and here are a few things that we should adjust:

@rfjschouten regarding your failing test: have you compared if the objects are identical? In your code, you can use console.log(log) to see which objects have been passed to the log and compare their values with the expected object in your test.

@waldekmastykarz Thanks for your review. I have changed the code with your suggestions. My API call had an accept header with verbose in it, which caused a response which was put in a 'd' variable. In my browser I did the same call but with accept nometadata. This was causing a difference in the input/output in the test. I have changed this and have 100% code coverage and test results. I will do a PR of my code.

I created PR 225 for this. I have 1 branche conflict on Commands.ts file. Not sure how this happened. I have gone through all documentation steps...

No worries, I'll fix it when merging the PR 馃憤

Meanwhile, care for taking another one @rfjschouten? 馃槃

@waldekmastykarz Yes, off course! I will take a look in the issue list and let you know...

Excellent @rfjschouten! Appreciate your help 馃憦

Was this page helpful?
0 / 5 - 0 ratings