Update testing documentation and improve test structure
All checks were successful
Test pipeline / test (push) Successful in 12s
All checks were successful
Test pipeline / test (push) Successful in 12s
This commit is contained in:
parent
1c84cae93b
commit
eb270cba9b
9 changed files with 617 additions and 20 deletions
62
tests/test_license_processor.py
Normal file
62
tests/test_license_processor.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
import pytest
|
||||
from doi2dataset import LicenseProcessor, License
|
||||
|
||||
def test_license_processor_cc_by():
|
||||
"""Test processing a CC BY license"""
|
||||
data = {
|
||||
"primary_location": {
|
||||
"license": "cc-by"
|
||||
}
|
||||
}
|
||||
license_obj = LicenseProcessor.process_license(data)
|
||||
assert isinstance(license_obj, License)
|
||||
assert license_obj.short == "cc-by"
|
||||
assert license_obj.name == "CC BY 4.0"
|
||||
assert license_obj.uri == "https://creativecommons.org/licenses/by/4.0/"
|
||||
|
||||
def test_license_processor_cc0():
|
||||
"""Test processing a CC0 license"""
|
||||
data = {
|
||||
"primary_location": {
|
||||
"license": "cc0"
|
||||
}
|
||||
}
|
||||
license_obj = LicenseProcessor.process_license(data)
|
||||
assert isinstance(license_obj, License)
|
||||
assert license_obj.short == "cc0"
|
||||
assert license_obj.name == "CC0 1.0"
|
||||
assert license_obj.uri == "https://creativecommons.org/publicdomain/zero/1.0/"
|
||||
|
||||
def test_license_processor_unknown_license():
|
||||
"""Test processing an unknown license"""
|
||||
data = {
|
||||
"primary_location": {
|
||||
"license": "unknown-license"
|
||||
}
|
||||
}
|
||||
license_obj = LicenseProcessor.process_license(data)
|
||||
assert isinstance(license_obj, License)
|
||||
assert license_obj.short == "unknown-license"
|
||||
# Verify properties exist and have expected values based on implementation
|
||||
assert license_obj.name == "unknown-license" or license_obj.name == ""
|
||||
assert hasattr(license_obj, "uri")
|
||||
|
||||
def test_license_processor_no_license():
|
||||
"""Test processing with no license information"""
|
||||
data = {
|
||||
"primary_location": {}
|
||||
}
|
||||
license_obj = LicenseProcessor.process_license(data)
|
||||
assert isinstance(license_obj, License)
|
||||
assert license_obj.short == "unknown"
|
||||
assert license_obj.name == ""
|
||||
assert license_obj.uri == ""
|
||||
|
||||
def test_license_processor_no_primary_location():
|
||||
"""Test processing with no primary location"""
|
||||
data = {}
|
||||
license_obj = LicenseProcessor.process_license(data)
|
||||
assert isinstance(license_obj, License)
|
||||
assert license_obj.short == "unknown"
|
||||
assert license_obj.name == ""
|
||||
assert license_obj.uri == ""
|
Loading…
Add table
Add a link
Reference in a new issue