Example #1
0
 def test_open(self):
     thing1 = self.get_thing()
     thing2 = Thing.open(self.fname)
     assert (thing1.id == thing2.id)
     assert (os.path.basename(thing1.links()[0]) == os.path.basename(
         thing2.links()[0]))
     assert (thing2.path == os.path.dirname(self.fname))
Example #2
0
 def test_save_remote_with_bad_signed_url(self):
     envs = dict(os.environ)
     thing = Thing.open(self.fname)
     os.environ['AWS_BUCKET_REGION'] = 'us-east-1'
     with self.assertRaises(STACError):
         thing.save('https://landsat-stac.s3.amazonaws.com/test/thing.json')
     os.environ.clear()
     os.environ.update(envs)
Example #3
0
 def test_get_parent(self):
     thing = Thing.open(os.path.join(testpath, 'catalog/eo/catalog.json'))
     parent = thing.parent()
     assert (parent.filename == os.path.join(testpath,
                                             'catalog/catalog.json'))
     thing.add_link('parent', 'catalog.json', title='parent2')
     with self.assertRaises(STACError):
         thing.parent()
     thing.clean_hierarchy()
     parent = thing.parent()
     assert (parent is None)
Example #4
0
 def test_save_remote_with_signed_url(self):
     thing = Thing.open(self.fname)
     thing.save_as('https://landsat-stac.s3.amazonaws.com/test/thing.json')
Example #5
0
 def test_save(self):
     thing = Thing.open(self.fname)
     thing.save()
     fout = os.path.join(self.path, 'test-save.json')
     thing.save_as(fout)
     assert (os.path.exists(fout))
Example #6
0
 def test_get_links(self):
     thing = Thing.open(
         'https://landsat-stac.s3.amazonaws.com/catalog.json')
     things = [Thing.open(t) for t in thing.links('child')]
     assert ('landsat-8-l1' in [t.id for t in things])
Example #7
0
 def test_open_missing_remote(self):
     with self.assertRaises(STACError):
         thing = Thing.open(
             'https://landsat-stac.s3.amazonaws.com/nosuchcatalog.json')
Example #8
0
 def test_open_remote(self):
     thing = Thing.open(
         'https://landsat-stac.s3.amazonaws.com/catalog.json')
     assert (thing.id == 'landsat-stac')
     assert (len(thing.data['links']) == 3)
Example #9
0
 def test_open_missing(self):
     with self.assertRaises(STACError):
         thing = Thing.open('nosuchfile.json')
Example #10
0
 def get_thing(self):
     """ Configure testing class """
     return Thing.open(self.fname)