def test_add_catalog(self): cat = Catalog.create(root='http://my.cat').save_as( os.path.join(self.path, 'catalog.json')) col = Catalog.open( os.path.join(testpath, 'catalog/eo/landsat-8-l1/catalog.json')) cat.add_catalog(col) child = [c for c in cat.children()][0] assert (child.id == col.id)
def test_cli_publish(self): cat = Catalog.create(root='https://my.cat').save_as('catalog.json') input = "sat-stac publish catalog.json https://my.kitten" sys.argv = split(input) cli() cat = Catalog.open('catalog.json') assert (cat.links('self')[0] == 'https://my.kitten/catalog.json') os.remove('catalog.json')
def test_add_item(self): cat = Catalog.create(root='http://my.cat').save( os.path.join(self.path, 'catalog.json')) col = Collection.open( os.path.join(testpath, 'catalog/eo/landsat-8-l1/catalog.json')) cat.add_catalog(col) item = Item.open( os.path.join(testpath, 'catalog/eo/landsat-8-l1/item.json')) col.add_item(item) assert (item.parent().id == 'landsat-8-l1')
def test_add_item_with_subcatalogs(self): cat = Catalog.create(root='http://my.cat').save( os.path.join(self.path, 'test_subcatalogs.json')) col = Collection.open( os.path.join(testpath, 'catalog/eo/landsat-8-l1/catalog.json')) cat.add_catalog(col) item = Item.open( os.path.join(testpath, 'catalog/eo/landsat-8-l1/item.json')) col.add_item(item, path='${landsat:path}/${landsat:row}/${date}') assert (item.root().id == cat.id) assert (item.collection().id == col.id) # test code using existing catalogs col.add_item(item, '${landsat:path}/${landsat:row}/${date}') assert (item.root().id == cat.id)
def test_main(self): """ Run main function """ # create test catalog fname = op.join(testpath, 'test_main', 'catalog.json') cat = Catalog.create(id='test').save_as(fname) assert(op.exists(fname))
def test_add_catalog_without_saving(self): cat = Catalog.create() with self.assertRaises(STACError): cat.add_catalog({})
def test_create_with_keywords(self): path = os.path.join(testpath, 'test-catalog', 'create_with_keywords') desc = 'this is a catalog' cat = Catalog.create(path, description=desc) assert (cat.description == desc)
def test_create(self): """ Create new catalog file """ cat = Catalog.create() assert (cat.id == 'stac-catalog')
def create_catalog(cls, name): path = os.path.join(cls.path, name) return Catalog.create(path)