Skip to content

Commit

Permalink
Add test for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnair1 committed Aug 20, 2022
1 parent 561bad9 commit cba3e3d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/datasets/test_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import pickle
from pathlib import Path
from typing import Dict
from typing import Dict, List

import pytest
import torch
Expand Down Expand Up @@ -49,6 +49,10 @@ class CustomVectorDataset(VectorDataset):
filename_glob = "*.geojson"


class CustomSentinelDataset(Sentinel2):
all_bands: List[str] = []


class CustomNonGeoDataset(NonGeoDataset):
def __getitem__(self, index: int) -> Dict[str, int]:
return {"index": index}
Expand Down Expand Up @@ -215,6 +219,14 @@ def test_no_data(self, tmp_path: Path) -> None:
with pytest.raises(FileNotFoundError, match="No RasterDataset data was found"):
RasterDataset(str(tmp_path))

def test_no_allbands(self) -> None:
with pytest.raises(AssertionError, match="all_bands must be specified"):
root = os.path.join("tests", "data", "sentinel2")
bands = ["B04", "B03", "B02"]
transforms = nn.Identity()
cache = True
CustomSentinelDataset(root, bands=bands, transforms=transforms, cache=cache)


class TestVectorDataset:
@pytest.fixture(scope="class")
Expand Down

0 comments on commit cba3e3d

Please sign in to comment.