File: conftest.py

package info (click to toggle)
stactools 0.5.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,796 kB
  • sloc: python: 4,498; xml: 554; sh: 395; makefile: 34
file content (46 lines) | stat: -rw-r--r-- 1,203 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import json
import shutil
from pathlib import Path

import pystac
import pytest

from tests import test_data


def expected_json(filename):
    path = Path(__file__).resolve().parent / "expected" / filename
    with open(path) as f:
        return json.load(f)


@pytest.fixture(scope="module")
def planet_disaster() -> pystac.Collection:
    return pystac.Collection.from_file(
        test_data.get_path("data-files/planet-disaster/collection.json")
    )


@pytest.fixture(scope="function")
def tmp_planet_disaster(tmp_path: Path) -> pystac.Collection:
    src = test_data.get_path("data-files/planet-disaster")
    dst = tmp_path / "planet-disaster"
    shutil.copytree(src, str(dst))

    return pystac.Collection.from_file(str(dst / "collection.json"))


@pytest.fixture(scope="function")
def tmp_item_path(tmp_path: Path) -> str:
    src = test_data.get_path("data-files/core/simple-item.json")
    dst = tmp_path / "item.json"
    shutil.copyfile(src, dst)
    return str(dst)


@pytest.fixture(scope="function")
def tmp_asset_path(tmp_path: Path) -> str:
    src = test_data.get_path("data-files/core/byte.tif")
    dst = tmp_path / "byte.tif"
    shutil.copyfile(src, dst)
    return str(dst)