Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ jobs:
- ubuntu-latest
- windows-latest
- macos-latest
exclude:
# https://github.com/stac-utils/pystac/issues/1470
- os: windows-latest
python-version: "3.13"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ stdout*
/integration*
.idea
.vscode
.actrc


# Sphinx documentation
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Write STAC v1.1.0 ([#1427](https://github.com/stac-utils/pystac/pull/1427))
- Use [uv](https://github.com/astral-sh/uv) for development dependencies and docs ([#1439](https://github.com/stac-utils/pystac/pull/1439))
- Correctly detect absolute file path ref on windows, reflecting change in python 3.13 ([#1475]https://github.com/stac-utils/pystac/pull/1475) (only effects python 3.13)

## [v1.11.0] - 2024-09-26

Expand Down
7 changes: 6 additions & 1 deletion tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,12 +832,17 @@ def test_generate_subcatalogs_works_for_subcatalogs_with_same_ids(self) -> None:
assert len(result) == 6

catalog.normalize_hrefs("/")

for item in catalog.get_items(recursive=True):
item_parent = item.get_parent()
assert item_parent is not None
parent_href = item_parent.self_href
path_to_parent, _ = os.path.split(parent_href)
subcats = [el for el in path_to_parent.split("/") if el]
# subcats = [el for el in path_to_parent.split("/") if el]
subcats = list(
Path(path_to_parent).parts[1:]
) # Skip drive letter if present (Windows)

assert len(subcats) == 2, f" for item '{item.id}'"

def test_map_items(self) -> None:
Expand Down
17 changes: 14 additions & 3 deletions tests/test_layout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import posixpath
import sys
import unittest
from collections.abc import Callable
from datetime import datetime, timedelta
Expand Down Expand Up @@ -413,6 +415,15 @@ class AsIsLayoutStrategyTest(unittest.TestCase):
def setUp(self) -> None:
self.strategy = AsIsLayoutStrategy()

path_includes_drive: bool = (
sys.version_info.major == 3
and sys.version_info.minor >= 13
and os.name == "nt"
)
self.expected_local_href = (
"/an/href" if not path_includes_drive else "D:/an/href"
)

def test_catalog(self) -> None:
cat = pystac.Catalog(id="test", description="test desc")
with self.assertRaises(ValueError):
Expand All @@ -421,7 +432,7 @@ def test_catalog(self) -> None:
href = self.strategy.get_href(
cat, parent_dir="https://example.com", is_root=True
)
self.assertEqual(href, "/an/href")
self.assertEqual(href, self.expected_local_href)

def test_collection(self) -> None:
collection = TestCases.case_8()
Expand All @@ -434,7 +445,7 @@ def test_collection(self) -> None:
href = self.strategy.get_href(
collection, parent_dir="https://example.com", is_root=True
)
self.assertEqual(href, "/an/href")
self.assertEqual(href, self.expected_local_href)

def test_item(self) -> None:
collection = TestCases.case_8()
Expand All @@ -444,7 +455,7 @@ def test_item(self) -> None:
self.strategy.get_href(item, parent_dir="http://example.com")
item.set_self_href("/an/href")
href = self.strategy.get_href(item, parent_dir="http://example.com")
self.assertEqual(href, "/an/href")
self.assertEqual(href, self.expected_local_href)


class APILayoutStrategyTest(unittest.TestCase):
Expand Down
24 changes: 23 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import sys
import time
import unittest
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -219,17 +220,38 @@ def test_is_absolute_href(self) -> None:
("item.json", False),
("./item.json", False),
("../item.json", False),
("/item.json", True),
("http://stacspec.org/item.json", True),
]

for href, expected in test_cases:
actual = is_absolute_href(href)
self.assertEqual(actual, expected)

def test_is_absolute_href_os_aware(self) -> None:
# Test cases of (href, expected)

# These tests ensure that is_absolute_href can respond correctly to the os
# in a forwards and backwards compatible way.
# Windows requires a drive name when python > 3.13 (https://docs.python.org/3/library/os.path.html#os.path.isabs)
is_py_3_13: bool = sys.version_info.major == 3 and sys.version_info.minor >= 13

is_windows = os.name == "nt"

test_cases = [
("/item.json", not (is_windows and is_py_3_13)),
("/home/someuser/Downloads/item.json", not (is_windows and is_py_3_13)),
("d:/item.json", is_windows),
("c:/files/more_files/item.json", is_windows),
]

for href, expected in test_cases:
actual = is_absolute_href(href)
self.assertEqual(actual, expected)

@pytest.mark.skipif(os.name != "nt", reason="Windows only test")
def test_is_absolute_href_windows(self) -> None:
# Test cases of (href, expected)

test_cases = [
("item.json", False),
(".\\item.json", False),
Expand Down
Loading