Skip to content

Update sdkVersion in graph_session.py #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2020

Conversation

rajatdiptabiswas
Copy link
Contributor

Fixes #42

Prepended sdkVersion with comma-separated new values in self.headers in graph_session.py
Modified a test and added another test to check whether the value has been updated correctly

Kindly check if everything is correct.
If something is wrong, please let me know. I'll try to get it fixed.

Fixes microsoftgraph#42

Prepended sdkVersion with comma separated new values in self.headers in graph_session.py
Modified a test and added another test to check whether the value has been updated correctly
@msftclas
Copy link

msftclas commented Apr 28, 2020

CLA assistant check
All CLA requirements met.

Comment on lines 23 to 27
if 'sdkVersion' not in self.headers:
self.headers.update({'sdkVersion': 'graph-python-' + SDK_VERSION})
else:
self.headers.update({'sdkVersion': 'graph-python-' + SDK_VERSION + ', '
+ self.headers.get('sdkVersion')})
Copy link
Contributor

@jobala jobala Apr 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this functionality in a private method _append_sdk_version and call the function in the constructor.

I prefer checking if sdkVersion is in headers first

if 'sdkVersion' in self.headers:
   ...
else:
  ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I'll make the changes!

@rajatdiptabiswas
Copy link
Contributor Author

I have come up with this definition of _append_sdk_version @jobala

def _append_sdk_version(self) -> None:
        """Updates sdkVersion in headers with comma-separated new values
        """
        if 'sdkVersion' in self.headers:
            self.headers.update({'sdkVersion': 'graph-python-' + SDK_VERSION + ', '
                                               + self.headers.get('sdkVersion')})
        else:
            self.headers.update({'sdkVersion': 'graph-python-' + SDK_VERSION})

Please let me know what the docstring should be. Is this correct?

@jobala
Copy link
Contributor

jobala commented Apr 29, 2020

Looks good @rajatdiptabiswas

Created a private method _append_sdk_version to update sdkVersion in headers
@rajatdiptabiswas
Copy link
Contributor Author

Made the changes you mentioned @jobala.
Kindly check if it looks fine now.

Thanks in advance!

Copy link
Contributor

@jobala jobala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jobala jobala merged commit f00e4b8 into microsoftgraph:dev Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update instead of overwriting sdkVersion in graph_session.py
3 participants