Python library for OSW validation
Project description
TDEI python lib OSW validation package
This package validates the OSW geojson file. Package requires a OSW zip file path
System requirements
Software | Version |
---|---|
Python | 3.10.x |
What this package does?
- It unzip the provided zip files
- Check for the required nodes and edges geojson files inside the unzipped folder
- Validate each file (nodes, edges and points) against schema, schema can be found here
- Return true or false according to validation
- you can check the error if it returned false.
Starting a new project with template
- Add
python-osw-validation
package as dependency in yourrequirements.txt
- or
pip install python-osw-validation
- Start using the packages in your code.
Initialize and Configuration
from python_osw_validation import OSWValidation
validator = OSWValidation(zipfile_path='<Zip file path>')
result = validator.validate()
print(result.is_valid)
print(result.errors) # will return first 20 errors by default if there are errors
result = validator.validate(max_errors=10)
print(result.is_valid)
print(result.errors) # will return first 10 errors depending on the max_errors parameter
Testing
The project is configured with python
to figure out the coverage of the unit tests. All the tests are in tests
folder.
-
To execute the tests, please follow the commands:
pip install -r requirements.txt
python -m unittest discover -v tests/unit_tests
-
To execute the code coverage, please follow the commands:
coverage run --source=src/python_osw_validation -m unittest discover -v tests/unit_tests
coverage html
// Can be run after 1st commandcoverage report
// Can be run after 1st command -
After the commands are run, you can check the coverage report in
htmlcov/index.html
. Open the file in any browser, and it shows complete coverage details -
The terminal will show the output of coverage like this
> coverage run --source=src/python_osw_validation -m unittest discover -v tests/unit_tests
test_duplicate_files (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_empty_directory (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_invalid_directory (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_missing_optional_file (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_no_geojson_files (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_valid_data_at_root (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_valid_data_inside_folder (test_extracted_data_validator.TestExtractedDataValidator) ... ok
test_edges_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_edges_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_edges_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_external_extension_file_inside_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_external_extension_file_inside_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_external_extension_file_inside_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_extra_field_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_id_missing_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_invalid_geometry_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_minimal_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_minimal_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_minimal_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_missing_identifier_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_no_entity_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_nodes_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_nodes_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_nodes_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_points_invalid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_points_invalid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_points_invalid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_valid_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_valid_zipfile_with_invalid_schema (test_osw_validation.TestOSWValidation) ... ok
test_valid_zipfile_with_schema (test_osw_validation.TestOSWValidation) ... ok
test_wrong_datatypes_zipfile (test_osw_validation.TestOSWValidation) ... ok
test_extract_invalid_zip (test_zipfile_handler.TestZipFileHandler) ... ok
test_extract_valid_zip (test_zipfile_handler.TestZipFileHandler) ... ok
test_remove_extracted_files (test_zipfile_handler.TestZipFileHandler) ... ok
----------------------------------------------------------------------
Ran 37 tests in 1284.068s
OK
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file python_osw_validation-0.2.7-py3-none-any.whl
.
File metadata
- Download URL: python_osw_validation-0.2.7-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 875a32cbeffb947ec25a1b4ca0795d7d9a988bf4cf6a1a2c0db48ba0c2d101b0 |
|
MD5 | 1be0bf2dc64528efd41ce9f9c10941d7 |
|
BLAKE2b-256 | 6ec4f1f24d2eb8c7901a68038fa50a21770a826f08c5cf92eab39d1961aa639f |