示例#1
0
 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)
示例#2
0
 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')
示例#3
0
 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')
示例#4
0
 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))
示例#6
0
 def test_add_catalog_without_saving(self):
     cat = Catalog.create()
     with self.assertRaises(STACError):
         cat.add_catalog({})
示例#7
0
 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)
示例#8
0
 def test_create(self):
     """ Create new catalog file """
     cat = Catalog.create()
     assert (cat.id == 'stac-catalog')
示例#9
0
 def create_catalog(cls, name):
     path = os.path.join(cls.path, name)
     return Catalog.create(path)