Esempio n. 1
0
 def test_upload(self):
     """ Upload file to S3 then delete """
     filename = os.path.basename(__file__)
     s3_uri = os.path.join(self.s3path, filename)
     uri = s3.upload(__file__, s3_uri)
     self.assertEqual(uri, s3_uri)
     s3.delete(s3_uri)
Esempio n. 2
0
    def test_exists_true(self):
        """ Check for existence of object that exists """

        uri = self.s3path + '/arealkey'
        s3.upload(self.payload, uri)
        self.assertTrue(s3.exists(uri))
        s3.delete(uri)
Esempio n. 3
0
    def test_download_json(self):
        """ Download file from S3 as JSON """
        json_obj = {'Body': {'this': 'that'}}
        self.s3.put_object(Bucket=self.bucket,
                           Key='prefix/test.json',
                           Body=json.dumps(json_obj))

        out = s3.download_json('s3://%s/prefix/test.json' % self.bucket)
        self.assertEqual(out, json_obj)
        s3.delete('s3://%s/prefix/test.json' % self.bucket)
Esempio n. 4
0
    def test_download(self):
        """ Download file from S3 """
        # first upload something
        uri = self.s3path + '/file.txt'
        s3.upload(self.payload, uri)

        fout = s3.download(uri, path=self.path)
        self.assertEqual(fout, os.path.join(self.path, 'file.txt'))
        s3.delete(uri)
        os.remove(fout)
Esempio n. 5
0
    def tearDownClass(cls):
        # delete the bucket
        uris = s3.list_objects('s3://%s' % cls.bucket)
        [s3.delete(uri) for uri in uris]
        cls.s3.delete_bucket(Bucket=cls.bucket)

        # delete temp folder
        rmtree(cls.path)
Esempio n. 6
0
 def _check_and_remove_remote_out(self, uris):
     """ Check for existence of remote files, then remove them """
     for uri in uris:
         self.assertTrue(s3.exists(uri))
         s3.delete(uri)
         self.assertFalse(s3.exists(uri))