def test_has_result_blank(): test_blank_result = {"data": {"repository": {"name": "example"}}} test_blank_user_result = {"data": {"user": {"name": "example"}}} test_blank_organ_result = {"data": {"organization": {"name": "example"}}} test_blank_pr = helpers.has_result(test_blank_result, 'pr') test_blank_commit = helpers.has_result(test_blank_result, 'commit') test_blank_user = helpers.has_result(test_blank_user_result, 'user_repository') test_blank_organ = helpers.has_result(test_blank_organ_result, 'repository') assert test_blank_pr == False assert test_blank_commit == False assert test_blank_user == False assert test_blank_organ == False
def test_has_result_fail(): test_none_result = { "data": { "repository": { "name": "example", "pullRequests": None, "ref": None } } } test_user_none_result = {"data": {"user": {"repositories": None}}} test_organ_none_result = {"data": {"organization": {"repositories": None}}} test_none_has_pr = helpers.has_result(test_none_result, 'pr') test_none_has_commit = helpers.has_result(test_none_result, 'commit') test_none_user_repository = helpers.has_result(test_user_none_result, 'user_repository') test_none_organ_repository = helpers.has_result(test_organ_none_result, 'repository') assert test_none_has_pr == False assert test_none_has_commit == False assert test_none_user_repository == False assert test_none_organ_repository == False
def test_has_result_success(): test_ok_result = { "data": { "repository": { "name": "example", "pullRequests": { "pageInfo": { "endCursor": "Y3Vyc29yOnYyOpHOBfDVGg==", "hasNextPage": True }, "nodes": [{ "publishedAt": "2016-12-29T15:46:23Z", "id": "MDExOlB1bGxSZXF1ZXN0OTk2NjkyNzQ=" }] }, "ref": { "target": { "history": { "pageInfo": { "endCursor": "56f531de853c2bbd974e6612c8d4cd1ab59f169a 0", "hasNextPage": True }, "totalCount": 217, "edges": [{ "node": { "author": { "email": "example" }, "pushedDate": "2018-08-22T06:56:48Z" } }] } } } } } } test_user_result = { "data": { "user": { "repositories": { "pageInfo": { "hasPreviousPage": True, "startCursor": "Y3Vyc29yOnYyOpHOCPih1A==" }, "nodes": [{ "name": "sspai-cse" }] } } } } test_organ_result = { "data": { "organization": { "repositories": { "pageInfo": { "hasPreviousPage": True, "startCursor": "MTg=" }, "nodes": [{ "name": "Grank" }] } } } } test_has_pr = helpers.has_result(test_ok_result, 'pr') test_has_commit = helpers.has_result(test_ok_result, 'commit') test_user_repository = helpers.has_result(test_user_result, 'user_repository') test_organ_repository = helpers.has_result(test_organ_result, 'repository') assert test_has_pr == True assert test_has_commit == True assert test_user_repository == True assert test_organ_repository == True