Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7114c67
Issues.py- basic code for grabbing issues
Feb 14, 2019
9494740
Issues.py prints out all issues' content
Feb 14, 2019
c3cb382
Looking at issue comments
Feb 14, 2019
4753520
Collecting usernames
Feb 15, 2019
2ad387b
Update issues.py
Feb 15, 2019
7dcdd58
added specific issue tracker
Feb 17, 2019
6298e97
Functions for number of issues and comments made
Feb 17, 2019
f4d5c9c
Merge branch 'issue-76-getissues' of github.com:GatorEducator/gatorgr…
Feb 17, 2019
9f29417
Added command line functionality for issues and commits
Feb 19, 2019
b65108b
Added error handling
Mar 1, 2019
77083ef
Changed what issues.py returns to invoke
Mar 1, 2019
9f4bf30
Test cases for issues.py
Mar 1, 2019
2594bb0
Added PyGithub to Pipfile
Mar 1, 2019
4d33917
Attempt to get code to pass travis
Mar 1, 2019
4651faf
Updated files to try and pass travis
Mar 1, 2019
fcbf2b8
Fixed flake8 issue
Mar 1, 2019
9cf379a
Added public repo token for tests
Mar 1, 2019
dc900e2
Split key cause I hope it will work
Mar 1, 2019
66a75a3
This will work this time
Mar 1, 2019
4c52294
Another commit to get this to pass
Mar 1, 2019
055ac56
Split Token into 2 parts to pass Travis CI
Mar 1, 2019
429dc6a
Merge branch 'issue-76-getissues' of github.com:GatorEducator/gatorgr…
Mar 7, 2019
41e7347
Made code in issues.py more uniform
Mar 7, 2019
aef913b
Added --state argument for issues
Mar 14, 2019
2811aeb
Merge branch 'master' into issue-76-getissues
Mar 14, 2019
7e20c67
Relock file
Mar 14, 2019
2d674ff
added test case for orchestrate.check_issues()
quigley-c Mar 14, 2019
573fce4
added test for orchestrate.check_issue_comments
quigley-c Mar 14, 2019
69fd9b1
added whitespace after token fragment definition
quigley-c Mar 14, 2019
f313094
fixed pylint line-break errors in arguments, orchestrate, and invoke
quigley-c Mar 14, 2019
33dc3d9
re-added quotations in docstring
quigley-c Mar 14, 2019
8333a14
fixed indentation warning in arguments for flake8
quigley-c Mar 14, 2019
3890804
fixed binary operator flake8 errors in arguments.py
quigley-c Mar 14, 2019
4d97d42
add test case to invoke.py
yeej2 Mar 16, 2019
676baa9
testing travis
yeej2 Mar 16, 2019
eb033b3
reformat test_invoke.py
yeej2 Mar 16, 2019
680d598
reformat files for travis
yeej2 Mar 16, 2019
a5e0e80
reformat files for travis
yeej2 Mar 16, 2019
772a616
lint files for travis
yeej2 Mar 16, 2019
f4fe1e2
added pylint disable to invoke.py
yeej2 Mar 16, 2019
2f53c3d
Finish test cases for invoke.py
yeej2 Mar 16, 2019
e847e78
add test cover for arguments.py
yeej2 Mar 17, 2019
ea774f0
add test case for line 251 in arguements.py
yeej2 Mar 17, 2019
20e6d54
add test for is_valid_state in arguments.py
yeej2 Mar 17, 2019
5ac4157
Finish code coverage for arguments.py
yeej2 Mar 17, 2019
6647bdd
fix code coverage
yeej2 Mar 28, 2019
53a297a
Fix test cases in test_issues
yeej2 Mar 28, 2019
2739097
Merge branch 'master' into issue-76-getissues
Michionlion Mar 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name = "pypi"
[packages]
gitpython = "*"
requests = ">=2.20.0"
pygithub = "*"

[dev-packages]
pylint = "*"
Expand Down
35 changes: 31 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added gator/.DS_Store
Binary file not shown.
103 changes: 102 additions & 1 deletion gator/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,57 @@ def parse(args):
# CORRECT WHEN: user provides this argument but not any other main arguments
gg_parser.add_argument("--commits", type=int, help="minimum number of git commits")

# specify a check for the number of issues raised in the Github issue tracker
# CORRECT WHEN: user provides this argument along with a github token, the
# name of the repo to check and the name of the user to check
gg_parser.add_argument("--issues", type=int, help="minimum number of issues raised")

# specify a check for the number of comments made on issues in the Github
# issue tracker
# CORRECT WHEN: user provides this argument along with a github token, the
# name of the repo to check and the name of the user to check
gg_parser.add_argument(
"--issue-comments", type=int, help="minimum number of comment made on issues"
)

# specify the github token to use for authenication
# CORRECT WHEN: user provides along with issues or issue comments, a repo
# name, and the user to check
gg_parser.add_argument(
"--token",
type=str,
metavar="TOKEN",
help="authenication token to access a github repository",
)

# specify the github repository to check the issues/comments of
# CORRECT WHEN: user provides along with issues or issue comments, a token,
# and the user to check
gg_parser.add_argument(
"--repo",
type=str,
metavar="REPO",
help="name of the repository to check the issues or comments of",
)

# specify the name of the user to check
# CORRECT WHEN: user provides along with issues or issue comments, a repo
# name, and a github token
gg_parser.add_argument(
"--name",
type=str,
metavar="NAME",
help="name of the creator of the issues or comments to check",
)

gg_parser.add_argument(
"--state",
type=str,
metavar="ISSUE_STATE",
default="all",
help="state of the issues to check, defaults to 'all'",
)

# specify a single file and a single directory
# CORRECT WHEN: user provides both of these
gg_parser.add_argument(
Expand Down Expand Up @@ -172,6 +223,48 @@ def is_valid_commits(args):
return False


def is_valid_issues(args):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This list is likely not correct -- there are not 6 different ways to call the check, right? These need to validate the combinations of arguments. How do you combine --name and --issue, for instance?

"""Checks if it is a valid issues specification"""
if args.issues is not None:
return True
return False


def is_valid_issue_comments(args):
"""Checks if it is a valid issue comment specification"""
if args.issue_comments is not None:
return True
return False


def is_valid_token(args):
"""Checks if it is a valid token specification"""
if args.token is not None:
return True
return False


def is_valid_repo(args):
"""Checks if it is a valid repo specification"""
if args.repo is not None:
return True
return False


def is_valid_name(args):
"""Checks if it is a valid name specification"""
if args.name is not None:
return True
return False


def is_valid_state(args):
"""Checks if it is a valid state"""
if args.state is not None:
return True
return False


# }}}

# Ancillary helper functions {{{
Expand Down Expand Up @@ -310,7 +403,8 @@ def verify(args):
if is_valid_exists(args):
# verified_arguments = True
file_verified.append(True)
# VERIFIED: correct check for comments with language in a file in a directory
# VERIFIED: correct check for comments with language in a file in a
# directory
if is_valid_comments(args) and is_valid_language(args):
# verified_arguments = True
file_verified.append(True)
Expand Down Expand Up @@ -369,6 +463,13 @@ def verify(args):
and not is_command_ancillary(args)
):
verified_arguments = True
# no file or directory details were specified or a command given
# and the argumenet is a request to check the number of issues a person
# has made in the github issue tracker
elif (is_valid_issues(args) or is_valid_issue_comments(args)) and (
is_valid_token(args) and is_valid_repo(args) and is_valid_name(args)
):
verified_arguments = True
return verified_arguments


Expand Down
60 changes: 60 additions & 0 deletions gator/invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from gator import repository
from gator import run
from gator import util
from gator import issues

JAVA = "Java"
PYTHON = "Python"
Expand Down Expand Up @@ -51,6 +52,65 @@ def invoke_commits_check(student_repository, expected_count, exact=False):
return did_check_pass


def invoke_issues_check(github_token, repo_name, username, expected_count, issue_state):
"""Checks to see if a student has made any issues in the issue tracker"""
# gets the number of issues the user has made in the tracker
did_check_pass, num_issues, err = issues.check_issues_made(
github_token, repo_name, username, expected_count, issue_state
)
message = (
str(username) + " has at made at least " + str(expected_count) + " issue(s)"
)
if err == -1:
diagnostic = "Invalid Github Token Supplied: '" + github_token + "'"
elif err == -2:
diagnostic = "Invalid Repository Supplied: '" + repo_name + "'"
else:
diagnostic = (
"Found "
+ str(num_issues)
+ " issue(s)"
+ " made by "
+ str(username)
+ " in the "
+ repo_name
+ " repository"
)
update_report(did_check_pass, message, diagnostic)
return did_check_pass


# pylint: disable=bad-continuation
def invoke_issue_comments_check(
github_token, repo_name, username, expected_count, issue_state
):
"""Checks to see if a student has made any comments on issues in the issue tracker"""
# gets the number of comments the user has made on issues in the tracker
did_check_pass, num_comments, err = issues.check_comments_made(
github_token, repo_name, username, expected_count, issue_state
)
message = (
str(username) + " has at made at least " + str(expected_count) + " comment(s)"
)
if err == -1:
diagnostic = "Invalid Github Token Supplied: '" + github_token + "'"
elif err == -2:
diagnostic = "Invalid Repository Supplied: '" + repo_name + "'"
else:
diagnostic = (
"Found "
+ str(num_comments)
+ " comment(s)"
+ " made by "
+ str(username)
+ " in the "
+ repo_name
+ " repository"
)
update_report(did_check_pass, message, diagnostic)
return did_check_pass


def invoke_file_in_directory_check(filecheck, directory):
"""Check to see if the file is in the directory"""
# get the home directory for checking and then check for file
Expand Down
45 changes: 45 additions & 0 deletions gator/issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Get issues from the Github issue tracker and performs checks on them"""

from github import Github
from github.GithubException import UnknownObjectException, BadCredentialsException


def check_issues_made(token, repo, name, expected, issue_state):
"""Returns the number of issues that the given user has made"""
# github access
g = Github(token)
# gets the repo
try:
repo = g.get_repo(repo)
except BadCredentialsException:
return False, 0, -1
except UnknownObjectException:
return False, 0, -2
issues_made = 0
for issue in repo.get_issues(state=issue_state):
if issue.user.login == name and issue.pull_request is None:
issues_made += 1
if issues_made >= expected:
return True, issues_made, 0
return issues_made >= expected, issues_made, 0


def check_comments_made(token, repo, name, expected, issue_state):
"""Returns the number of comments that the given user has made"""
# github access
g = Github(token)
# gets the repo
try:
repo = g.get_repo(repo)
except BadCredentialsException:
return False, 0, -1
except UnknownObjectException:
return False, 0, -2
comments_made = 0
for issue in repo.get_issues(state=issue_state):
for comment in issue.get_comments():
if comment.user.login == name and issue.pull_request is None:
comments_made += 1
if comments_made >= expected:
return True, comments_made, 0
return comments_made >= expected, comments_made, 0
42 changes: 42 additions & 0 deletions gator/orchestrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,46 @@ def check_commits(system_arguments):
return actions


def check_issues(system_arguments):
"""Check the number of issues made in the github issue tracker"""
actions = []
if system_arguments.issues is not None:
actions.append(
[
INVOKE,
"invoke_issues_check",
[
system_arguments.token,
system_arguments.repo,
system_arguments.name,
system_arguments.issues,
system_arguments.state,
],
]
)
return actions


def check_issue_comments(system_arguments):
"""Check the number of comments on issues made in the github issue tracker"""
actions = []
if system_arguments.issue_comments is not None:
actions.append(
[
INVOKE,
"invoke_issue_comments_check",
[
system_arguments.token,
system_arguments.repo,
system_arguments.name,
system_arguments.issue_comments,
system_arguments.state,
],
]
)
return actions


def check_exists(system_arguments):
"""Check the existence of a file in directory and return desired actions"""
actions = []
Expand Down Expand Up @@ -305,6 +345,8 @@ def check(system_arguments):
"check_count_file",
"check_count_command",
"check_executes_command",
"check_issues",
"check_issue_comments",
]
# iterate through all of the possible checks
for a_check in checks:
Expand Down
Loading