def test_get_pushlogs(plm, plrdm, monkeypatch): """Test the get_pushlogs method.""" def mock_plrdm(): return plrdm monkeypatch.setattr(factory, 'get_plrdm', mock_plrdm) def mock_plm(): return plm monkeypatch.setattr(factory, 'get_plm', mock_plm) data1 = get_pushlog_dict_set() plm._insert_branch_pushlogs( get_branch_id(plm), data1, ) result = pushlog_refdata.get_pushlogs( startdate=1341451080, enddate=1341494822, ) exp = { 23049: { "branch_name": "Firefox", "revisions": [ "fbd96a0bcc00", "fe305819d2f2" ] }, 23052: { "branch_name": "Firefox", "revisions": [ "ea890a6eed56", "bd74a2949929", "5d6c06259bb1", "7209f9f14a7d" ] }, 23046: { "branch_name": "Firefox", "revisions": [ "785345035a3b" ] } } assert result == exp
def test_get_pushlogs(plm, plrdm, monkeypatch): """Test the get_pushlogs method.""" def mock_plrdm(): return plrdm monkeypatch.setattr(factory, 'get_plrdm', mock_plrdm) def mock_plm(): return plm monkeypatch.setattr(factory, 'get_plm', mock_plm) data1 = get_pushlog_dict_set() plm._insert_branch_pushlogs( get_branch_id(plm), data1, ) result = pushlog_refdata.get_pushlogs( startdate=1341451080, enddate=1341494822, ) exp = { 23049: { "branch_name": "Firefox", "revisions": ["fbd96a0bcc00", "fe305819d2f2"] }, 23052: { "branch_name": "Firefox", "revisions": ["ea890a6eed56", "bd74a2949929", "5d6c06259bb1", "7209f9f14a7d"] }, 23046: { "branch_name": "Firefox", "revisions": ["785345035a3b"] } } assert result == exp
def get_pushlogs(request): """ Get a list of pushlogs with their revisions. branches: optional. The comma-separated list of branches to show data for. If not provided, return data for all branches. days_ago: required. Number of days ago for the "start" of the range. numdays: optional. Number of days since days_ago. Will default to "all since days ago" """ if not request.GET.get("days_ago"): return HttpResponse(REQUIRE_DAYS_AGO, status=400) range = get_range(request) branches = request.GET.get("branches", None) if branches: branches = branches.split(",") stats = pushlog_refdata.get_pushlogs( range["start"], range["stop"], branches, ) return HttpResponse(json.dumps(stats), content_type=API_CONTENT_TYPE)