コード例 #1
0
 def test_init(self):
     thing1 = self.get_thing()
     assert (thing1.id == 'stac')
     assert (len(thing1.links()) == 3)
     assert (len(thing1.links('self')) == 1)
     data = thing1.data
     del data['links']
     thing2 = Thing(data)
     assert (thing2.links() == [])
     with self.assertRaises(STACError):
         thing2.save()
     print(thing1)
コード例 #2
0
ファイル: test_thing.py プロジェクト: palmerj/sat-stac
 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))
コード例 #3
0
ファイル: test_thing.py プロジェクト: palmerj/sat-stac
 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)
コード例 #4
0
ファイル: test_thing.py プロジェクト: palmerj/sat-stac
 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)
コード例 #5
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')
コード例 #6
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))
コード例 #7
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])
コード例 #8
0
 def test_open_missing_remote(self):
     with self.assertRaises(STACError):
         thing = Thing.open(
             'https://landsat-stac.s3.amazonaws.com/nosuchcatalog.json')
コード例 #9
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)
コード例 #10
0
 def get_thing(self):
     """ Configure testing class """
     with open(self.fname) as f:
         data = json.loads(f.read())
     return Thing(data)
コード例 #11
0
ファイル: test_thing.py プロジェクト: palmerj/sat-stac
 def test_open_missing(self):
     with self.assertRaises(STACError):
         thing = Thing.open('nosuchfile.json')
コード例 #12
0
ファイル: test_thing.py プロジェクト: palmerj/sat-stac
 def test_init_error(self):
     with self.assertRaises(STACError):
         Thing({})
コード例 #13
0
ファイル: test_thing.py プロジェクト: palmerj/sat-stac
 def get_thing(self):
     """ Configure testing class """
     return Thing.open(self.fname)