def test_no_file_exception():
    args.file = "wrong/file/path"

    with pytest.raises(FileNotFoundError):
        checkFile.checkFile(args)

    args.file = "resources/test.html"
def test_parseWebAddress():

    lineToParse = "https://www.google.com/search?q=help"

    cF = checkFile.checkFile(args)

    assert cF.parseWebAddress(
        lineToParse) == "https://www.google.com/search?q=help"
def test_headRequest_404(mock_headRequest):

    link = "http://google.cim"
    mock_headRequest.return_value = {
        "url": link,
        "status": 404,
        "secured": False
    }
    cF = checkFile.checkFile(args)

    assert cF.headRequest(link) == {
        "url": "http://google.cim",
        "status": 404,
        "secured": False,
    }
Example #4
0
def main(args):
    cf = checkFile.checkFile(args)
    cf.checkThatFile()

    if args.good:
        if args.json:
            cf.printGoodResultsJSON()
        else:
            cf.printGoodResults()
    elif args.bad:
        if args.json:
            cf.printBadResultsJSON()
        else:
            cf.printBadResults()
    else:
        if args.json:
            cf.printAllJSON()
        else:
            cf.printAll()
Example #5
0
                           '--secureHttp',
                           dest='secureHttp',
                           action='store_true',
                           help="flag to check if https works on http links",
                           required=False)
    argParser.add_argument('-j',
                           '--json',
                           dest='json',
                           action='store_true',
                           help="display output as JSON",
                           required=False)
    argParser.add_argument(
        '-a',
        '--all',
        action='store_true',
        help="Flag to display all links (defualt behaviour)",
        required=False)
    argParser.add_argument('-g',
                           '--good',
                           action='store_true',
                           help="Flag to display only good links",
                           required=False)
    argParser.add_argument('-b',
                           '--bad',
                           action='store_true',
                           help="Flag to display only bad links",
                           required=False)
    args = argParser.parse_args()

    checkFile(args)