def test_get_comment_body_cla_fail_no_user_id_and_user_id(): """ Test CLA comment body for case CLA fail check with no user id and existing user id """ # case with missing list with user id existing author_name = "wanyaland" response = get_comment_body( "github", SIGN_URL, [], [ (GITHUB_FAKE_SHA, ["12", author_name, "*****@*****.**"]), (GITHUB_FAKE_SHA_2, [None, author_name, " [email protected]"]), ], ) expected = ( f"<ul><li>" + "[" + FAILED + "](" + SIGN_URL + ") " + author_name + " The commit (" + " ,".join([GITHUB_FAKE_SHA]) + ") is not authorized under a signed CLA. " + f"[Please click here to be authorized]({SIGN_URL}). For further assistance with " + f"EasyCLA, [please submit a support request ticket]({SUPPORT_URL})." + "</li>" + "<li>" + FAILED + "The commit (" + " ,".join([GITHUB_FAKE_SHA_2]) + ") is missing the User's ID, preventing the EasyCLA check. [Consult GitHub Help](" + GITHUB_HELP_URL + ") to resolve." + "</li></ul>") assert response == expected
def test_get_comment_body_whitelisted_missing_user(): """ Test CLA comment body for case of a whitelisted user that has not confirmed affiliation """ is_whitelisted = True author = "foo" signed = [] missing = [(GITHUB_FAKE_SHA, ["12", author, "*****@*****.**", is_whitelisted])] response = get_comment_body("github", SIGN_URL, signed, missing) expected = ( f"<ul><li>" + author + "(" + " ,".join([GITHUB_FAKE_SHA]) + ") " + "is authorized, but they must confirm " + "their affiliation with their company. " + f'[Start the authorization process by clicking here]({SIGN_URL}), click "Corporate",' + "select the appropriate company from the list, then confirm " + "your affiliation on the page that appears. For further assistance with EasyCLA, " + f"[please submit a support request ticket]({SUPPORT_URL})." + "</li>" + "</ul>" ) assert response == expected
def test_get_comment_body_no_user_id(): """ Test CLA comment body for case CLA test failure when commit has no user ids """ # case with missing list with no authors response = get_comment_body( "github", SIGN_URL, [], [(GITHUB_FAKE_SHA, [None, 'foo', '*****@*****.**']), (GITHUB_FAKE_SHA_2, [None, 'fake', '*****@*****.**'])]) expected = ( f"<ul><li>" + FAILED + "The commit (" + " ,".join([GITHUB_FAKE_SHA, GITHUB_FAKE_SHA_2]) + ") is missing the User's ID,preventing the EasyCLA check.[Consult GitHub Help](" + GITHUB_HELP_URL + ") to resolve." + "</li></ul>") assert response == expected
def test_get_comment_body_no_user_id(): """ Test CLA comment body for case CLA test failure when commit has no user ids """ # case with missing list with no authors response = get_comment_body( "github", SIGN_URL, [], [(GITHUB_FAKE_SHA, [None, "foo", "*****@*****.**"]), (GITHUB_FAKE_SHA_2, [None, "fake", "*****@*****.**"])], ) expected = ( f"<ul><li>" + FAILED + "The commit (" + " ,".join([GITHUB_FAKE_SHA, GITHUB_FAKE_SHA_2]) + ") is missing the User's ID, preventing the EasyCLA check. [Consult GitHub Help](" + GITHUB_HELP_URL + ") to resolve. For further assistance with EasyCLA, " + f"[please submit a support request ticket]({SUPPORT_URL})." + "</li></ul>") assert response == expected