Example #1
0
def test_fetch_review_requests(mock_method):
  mock_method.return_value = '''{
    "stat" : "ok",
    "review_requests" : [
      { "id" : 123 }, { "id" : 456 }
    ]
  }'''
  rbs = ReviewBoardServer('http://example.com', username='******', password='******')
  assert len(rbs.fetch_review_requests()) == 2
  assert mock_method.mock_calls == [
    call(rbs, "api/review-requests/?start=0&max-results=25",
         None, None, {'Accept': 'application/json'}, method=None)
  ]
Example #2
0
def test_get_diffs(mock_method):
  mock_method.return_value = '''{
    "stat" : "ok",
    "diffs" : [
      { "id" : 123 }, { "id" : 456 }
    ]
  }'''
  rbs = ReviewBoardServer('http://example.com', username='******', password='******')
  rb_id = 123
  assert len(rbs.get_diffs(rb_id)) == 2
  assert mock_method.mock_calls == [
    call(rbs, "api/review-requests/%d/diffs/" % rb_id,
         None, None, {'Accept': 'application/json'}, method=None)
  ]
Example #3
0
def test_get_files(mock_method):
  mock_method.return_value = '''{
    "stat" : "ok",
    "files" : [
      { "id" : 123 }, { "id" : 456 }
    ]
  }'''
  rbs = ReviewBoardServer('http://example.com', username='******', password='******')
  rb_id = 123
  revision = 456
  assert len(rbs.get_files(rb_id, revision)) == 2
  assert mock_method.mock_calls == [
    call(rbs, "api/review-requests/%d/diffs/%d/files/?start=0&max-results=25" % (rb_id, revision),
         None, None, {'Accept': 'application/json'}, method=None)
  ]
Example #4
0
def test_fetch_review_requests(mock_method):
    mock_method.return_value = '''{
    "stat" : "ok",
    "review_requests" : [
      { "id" : 123 }, { "id" : 456 }
    ]
  }'''
    rbs = ReviewBoardServer('http://example.com',
                            username='******',
                            password='******')
    assert len(rbs.fetch_review_requests()) == 2
    assert mock_method.mock_calls == [
        call(rbs,
             "api/review-requests/?start=0&max-results=25",
             None,
             None, {'Accept': 'application/json'},
             method=None)
    ]
Example #5
0
def test_get_diffs(mock_method):
    mock_method.return_value = '''{
    "stat" : "ok",
    "diffs" : [
      { "id" : 123 }, { "id" : 456 }
    ]
  }'''
    rbs = ReviewBoardServer('http://example.com',
                            username='******',
                            password='******')
    rb_id = 123
    assert len(rbs.get_diffs(rb_id)) == 2
    assert mock_method.mock_calls == [
        call(rbs,
             "api/review-requests/%d/diffs/" % rb_id,
             None,
             None, {'Accept': 'application/json'},
             method=None)
    ]
Example #6
0
def test_get_files(mock_method):
    mock_method.return_value = '''{
    "stat" : "ok",
    "files" : [
      { "id" : 123 }, { "id" : 456 }
    ]
  }'''
    rbs = ReviewBoardServer('http://example.com',
                            username='******',
                            password='******')
    rb_id = 123
    revision = 456
    assert len(rbs.get_files(rb_id, revision)) == 2
    assert mock_method.mock_calls == [
        call(rbs,
             "api/review-requests/%d/diffs/%d/files/?start=0&max-results=25" %
             (rb_id, revision),
             None,
             None, {'Accept': 'application/json'},
             method=None)
    ]
Example #7
0
def test_get_url():
    for url in ['http://reviewboard.com', 'http://reviewboard.com/']:
        assert ReviewBoardServer(
            url, username='******', password='******').get_url(
                123456) == 'http://reviewboard.com/r/123456'