Example #1
0
 def test_response_is_successful(self, mock_get):
     mock_response = MagicMock()
     mock_response.status_code = 200
     mock_response.json.return_value = [_get_commit_response()] * 10
     mock_get.return_value = mock_response
     result = github.get_commits('madewithbytes', 'us_ignite')
     extra_data = {'cleaned_commit': 'Hello!'}
     eq_(result, [_get_commit_response(extra_data)] * 5)
Example #2
0
def render_github(parsed_url):
    path_bits = parsed_url.path.split('/')
    try:
        username = path_bits.pop(1)
    except IndexError:
        return u''
    try:
        project = path_bits.pop(1)
    except IndexError:
        project = None
    # Latest commits:
    commit_list = github.get_commits(username, project) if project else []
    context = {
        'parsed_url': parsed_url,
        'username': username,
        'project': project,
        'commit_list': commit_list,
    }
    return render_to_string('apps/includes/github.html', context)
Example #3
0
 def test_not_ok_response_is_successfully_handled(self, mock_get):
     mock_response = MagicMock()
     mock_response.status_code = 405
     mock_get.return_value = mock_response
     result = github.get_commits('madewithbytes', 'us_ignite')
     eq_(result, [])
Example #4
0
 def test_github_response_fails_gracefully(self, mock_get):
     mock_get.side_effect = ValueError
     result = github.get_commits('madewithbytes', 'us_ignite')
     eq_(result, [])