Skip to content

Commit

Permalink
Refactor test_pr.py to a more coherent design.
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Jul 16, 2012
1 parent 87d86c1 commit 28e099c
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 170 deletions.
13 changes: 12 additions & 1 deletion tools/gh_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
# password
fake_username = 'ipython_tools'

class Obj(dict):
"""Dictionary with attribute access to names."""
def __getattr__(self, name):
try:
return self[name]
except KeyError:
raise AttributeError(name)

def __setattr__(self, name, val):
self[name] = val

token = None
def get_auth_token():
global token
Expand Down Expand Up @@ -88,7 +99,7 @@ def get_pull_request(project, num, github_api=3):
response.raise_for_status()
if github_api == 2 :
return json.loads(response.text)['pull']
return json.loads(response.text)
return json.loads(response.text, object_hook=Obj)

def get_pulls_list(project, github_api=3):
"""get pull request list
Expand Down
12 changes: 6 additions & 6 deletions tools/post_pr_test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python
"""Post the results of a pull request test to Github.
"""
from test_pr import load_results, post_logs, post_results_comment, print_results
from test_pr import TestRun

num, results, pr, unavailable_pythons = load_results()
results_urls = post_logs(results)
print_results(pr, results_urls, unavailable_pythons)
post_results_comment(pr, results_urls, num, unavailable_pythons)
testrun = TestRun.load_results()
testrun.post_logs()
testrun.print_results()
testrun.post_results_comment()

print()
print("Posted test results to pull request")
print(" " + pr['html_url'])
print(" " + testrun.pr['html_url'])
Loading

0 comments on commit 28e099c

Please sign in to comment.