1
mirror of https://github.com/public-apis/public-apis synced 2024-11-21 10:04:15 +01:00
public-apis/scripts
Matheus Felipe c2bdd9e5fc
Fix false negative http code 404 in verification
Some links when they were being checked returned the http code 404,
but the links were working correctly.

This was happening because before the request the link was concatenated
with the / character at the end, making it a different link from the
original. If the original link didn't have a path that is
accessed by / at the end, it would return a 404 error.

This behavior made it a false negative.
2022-02-07 07:09:01 -03:00
..
tests Create tests to check_file_format 2022-01-17 16:19:39 -03:00
validate Fix false negative http code 404 in verification 2022-02-07 07:09:01 -03:00
github_pull_request.sh Modify execute permission 2022-01-18 03:30:13 -03:00
README.md Add possibility to run duplicate link check only 2022-01-18 02:06:21 -03:00
requirements.txt Create new requirements file 2022-01-11 02:42:28 -03:00

Public APIs Scripts

This directory contains all validation and testing scripts used by Public APIs.

scripts
│   github_pull_request.sh  # used to validate changes of a pull request
│   requirements.txt  # contains dependencies of validate package
│
├───tests  # contains all unit tests from the validate package
│       test_validate_format.py
│       test_validate_links.py
│
└───validate  # validate package
        format.py
        links.py

Install dependencies

You must have python installed to use these scripts.

it is also necessary to install the validation package dependencies, use pip package manager for this:

$ python -m pip install -r scripts/requirements.txt

Run validations

To run format validation on the README.md file, being in the root directory of public-apis, run:

$ python scripts/validate/format.py README.md

To run link validation on the README.md file, being in the root directory of public-apis, run:

$ python scripts/validate/links.py README.md

As there are many links to check, this process can take some time. If your goal is not to check if the links are working, you can only check for duplicate links. Run:

$ python scripts/validate/links.py README.md -odlc

-odlc is an abbreviation of --only_duplicate_links_checker

Running Tests

To run all tests it is necessary to change to the scripts directory:

$ cd scripts

then run:

$ python -m unittest discover tests/ --verbose

To run only the format tests, run:

$ python -m unittest discover tests/ --verbose --pattern "test_validate_format.py"

To run only the links tests, run:

$ python -m unittest discover tests/ --verbose --pattern "test_validate_links.py"