Ejemplo n.º 1
0
def test_get_comments_cache():
    return_data = {'foo': 'bar'}
    requester = mock.MagicMock()
    pr = GitHubReporter(requester, 'test-repo')
    pr._comments = return_data
    result = pr.get_comments('example.com')
    assert result == return_data
    assert not requester.get.called
Ejemplo n.º 2
0
def test_get_comments_no_cache():
    return_data = {'foo': 'bar'}
    requester = mock.MagicMock()
    requester.get.return_value.json = lambda: return_data
    requester.get.return_value.status_code = 200
    pr = GitHubReporter(requester, 'repo-name')
    result = pr.get_comments('example.com')
    assert result == return_data
    assert pr._comments == return_data
    requester.get.assert_called_with('example.com')
Ejemplo n.º 3
0
def test_get_comments_error():
    requester = mock.MagicMock()
    requester.get.return_value.status_code = 400
    pr = GitHubReporter(requester, 'test-repo')
    result = pr.get_comments('example.com')
    assert len(result) == 0