def test_pull_gzip_from_s3(self): """ Tests that a gzip is pulled from S3 and unpacked """ output_path = '{0}/test_out/'.format(os.getcwd()) try: with MockElasticsearchStream(): dashboard.pull_from_s3( output_directory=output_path, s3_details=self.s3_details ) for sub_type in ['search', 'visualization', 'dashboard']: self.assertTrue( os.path.isdir('{0}{1}'.format(output_path, sub_type)) ) gb = glob.glob('{0}{1}/*'.format(output_path, sub_type)) self.assertTrue( len(gb) > 0 ) except Exception as error: self.fail(error) finally: pass os.remove('/tmp/tmp.tar.gz') shutil.rmtree('{0}'.format(output_path))
def test_pull_gzip_from_s3(self): """ Tests that a gzip is pulled from S3 and unpacked """ helper_make_all() s3_resource = boto3.resource('s3') s3_resource.create_bucket(Bucket=self.s3_details['bucket']) with open('/tmp/tmp.tar.gz', 'rb') as f: binary = f.read() s3_resource.Bucket(self.s3_details['bucket']).put_object( Key='dashboard.tar.gz', Body=binary ) output_path = '{0}/test_out/'.format(os.getcwd()) dashboard.pull_from_s3( output_directory=output_path, s3_details=self.s3_details ) for sub_type in ['search', 'visualization', 'dashboard']: self.assertTrue( os.path.isdir('{0}{1}'.format(output_path, sub_type)) ) gb = glob.glob('{0}{1}/*'.format(output_path, sub_type)) self.assertTrue( len(gb) > 0 ) os.remove('/tmp/tmp.tar.gz') shutil.rmtree('{0}'.format(output_path))