Skip to content

Commit

Permalink
Upgrade to 0.5.4; write test to verify fix to #31
Browse files Browse the repository at this point in the history
  • Loading branch information
lossyrob committed Jan 15, 2021
1 parent 95aeae2 commit da80295
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stactools_core/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pystac[validation]==0.5.3
pystac[validation]==0.5.4
aiohttp==3.7.3
fsspec==0.8.4
requests==2.25.0
Expand Down
38 changes: 38 additions & 0 deletions tests/cli/commands/test_copy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
from tempfile import TemporaryDirectory
from typing import cast

import pystac
from pystac.utils import is_absolute_href, make_absolute_href

from stactools.cli.commands.copy import create_copy_command
from tests.utils import (TestCases, CliTestCase)
Expand All @@ -22,3 +24,39 @@ def test_copy(self):
copy_cat_ids = set([i.id for i in copy_cat.get_all_items()])

self.assertEqual(copy_cat_ids, item_ids)

def test_copy_to_relative(self):
cat = TestCases.planet_disaster()

with TemporaryDirectory() as tmp_dir:
cat.make_all_asset_hrefs_absolute()
cat.normalize_hrefs(tmp_dir)
cat.save(catalog_type=pystac.CatalogType.ABSOLUTE_PUBLISHED)

cat2_dir = os.path.join(tmp_dir, 'second')

command = [
'copy',
'-t', 'SELF_CONTAINED',
'-a',
cat.get_self_href(),
cat2_dir
]
self.run_command(command)
cat2 = pystac.read_file(os.path.join(cat2_dir, 'collection.json'))
for item in cat2.get_all_items():
item_href = item.get_self_href()
for asset in item.assets.values():
href = asset.href
self.assertFalse(is_absolute_href(href))
common_path = os.path.commonpath([
os.path.dirname(item_href),
make_absolute_href(href, item_href)
])
self.assertTrue(common_path, os.path.dirname(item_href))






0 comments on commit da80295

Please sign in to comment.