Skip to content

API: fix GitHub access tests #134

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 7 commits into from
Oct 6, 2021
Merged

Conversation

carterbox
Copy link
Collaborator

Fixes broken tests by updating GitHub authentication from username/password to personal token and by changing the branch pointer to "main" from "master".


uname, pwd = open(creds_file_name, 'r').read().strip().split()
return dict(user=uname, password=pwd)
return open(creds_file_name, 'r').read().strip().split()[0]
Copy link
Owner

Choose a reason for hiding this comment

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

I need to keep the credentials file to contain: github_email password token with any whitespace separator. As written, this returns github_email which is then used below as token.

Copy link
Owner

Choose a reason for hiding this comment

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

this file is used by multiple software, needs to keep same structure

Copy link
Owner

Choose a reason for hiding this comment

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

The file can keep its structure but, to return the token, this function must return item the last item ([-1]) from the list. Will this also work with your own version of the file that only contains the token?

@@ -59,45 +59,45 @@

def get_BasicAuth_credentials(creds_file_name = None):
Copy link
Owner

Choose a reason for hiding this comment

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

This function gets the GitHub credentials but they are no longer BasicAuth (username & password). I suggest changing the name to get_GitHub_credentials.

Copy link
Owner

Choose a reason for hiding this comment

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

Request function name be changed.

:param str repo_name: name of repository in https://github.com/nexusformat (default: *definitions*)
:returns bool: True if using GitHub credentials
"""
repo_name = repo_name or self.appName


token = get_BasicAuth_credentials() if token is None else token
Copy link
Owner

Choose a reason for hiding this comment

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

with above refactor so get_GitHub_credentials() returns a dict:

token = get_GitHub_credentials()["token"] if token is None else token

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why should get_GitHub_credentials return a dictionary? Only the token is ever used.

Copy link
Owner

Choose a reason for hiding this comment

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

That's true within this software. But on my system, the exact same file is used in other contexts that need the additional content and formatting. A change here would compel revision to the other software.

Why should the current interface change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you import get_GitHub_credentials from punx to other packages?

@@ -158,15 +162,15 @@ def download(self):
#requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
disable_warnings(InsecureRequestWarning)

creds = get_BasicAuth_credentials()
token = get_BasicAuth_credentials()
Copy link
Owner

Choose a reason for hiding this comment

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

op cit.

token = get_GitHub_credentials()["token"]

Copy link
Owner

@prjemian prjemian left a comment

Choose a reason for hiding this comment

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

@carterbox : Thanks for the PR! Changes requested as noted.

@prjemian
Copy link
Owner

prjemian commented Oct 6, 2021

Also, once we are done with technical corrections and updates to make the code compliant with Python3, I intend to apply black to set the code style compatible with PEP8. In a separate PR.

@prjemian
Copy link
Owner

prjemian commented Oct 6, 2021

BTW, the commands to run the tests are listed in ./.travis.yml but these have been superceded by pytest which can run all the tests in the repo. Any future unit tests should be written with pytest, instead of unittest.

@carterbox carterbox requested a review from prjemian October 6, 2021 16:36
Copy link
Owner

@prjemian prjemian left a comment

Choose a reason for hiding this comment

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

Structure of credentials file and how to get the token from the file still needs changes.

@carterbox
Copy link
Collaborator Author

Ya, I just wanted feedback on my comments before I proceeded with any changes. Thanks!

@carterbox carterbox requested a review from prjemian October 6, 2021 18:19
Copy link
Owner

@prjemian prjemian left a comment

Choose a reason for hiding this comment

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

@carterbox : LGTM, Thanks! Merge when ready!

@prjemian prjemian added the bug label Oct 6, 2021
@carterbox carterbox merged commit bc288ee into prjemian:main Oct 6, 2021
@carterbox carterbox deleted the fix-github-tests branch October 6, 2021 21:36
@prjemian prjemian mentioned this pull request Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants