Ejemplo n.º 1
0
 def _get_storage(self):
     if self._storage is None:
         sharing_mode = config.get_option("global.sharingMode")
         if sharing_mode == "s3":
             self._storage = S3Storage()
         elif sharing_mode == "file":
             self._storage = FileStorage()
         else:
             raise RuntimeError("Unsupported sharing mode '%s'" % sharing_mode)
     return self._storage
Ejemplo n.º 2
0
 def test_public_url(self, creds, static_files):
     creds.return_value = {
         'bucket': 'share.streamlit.io',
         'url': 'https://share.streamlit.io/',
         'accessKeyId': 'ACCESS_KEY_ID',
         'secretAccessKey': 'SECRERT_ACCESS_KEY',
     }
     static_files.return_value = [('index.html', 'some data')], hashlib.md5()
     set_option('global.sharingMode', 'streamlit-public')
     s3 = S3Storage()
     self.assertEqual(s3._url, 'https://share.streamlit.io/')
Ejemplo n.º 3
0
    def test_private_url(self, static_files):
        static_files.return_value = [("index.html", "some data")], hashlib.md5()

        set_option("global.sharingMode", "s3")
        set_option("s3.bucket", "buckets")
        set_option("s3.accessKeyId", "ACCESS_KEY_ID")
        set_option("s3.secretAccessKey", "SECRET_ACCESS_KEY")
        s3 = S3Storage()
        self.assertEqual(s3._url, None)
        idx = s3._web_app_url.index("/", 8)
        self.assertEqual(s3._web_app_url[0:idx], "https://buckets.s3.amazonaws.com")
Ejemplo n.º 4
0
    def test_private_url(self, static_files):
        static_files.return_value = [('index.html', 'some data')], hashlib.md5()

        set_option('global.sharingMode', 's3')
        set_option('s3.bucket', 'buckets')
        set_option('s3.accessKeyId', 'ACCESS_KEY_ID')
        set_option('s3.secretAccessKey', 'SECRET_ACCESS_KEY')
        s3 = S3Storage()
        self.assertEqual(s3._url, None)
        idx = s3._web_app_url.index('/', 8)
        self.assertEqual(s3._web_app_url[0:idx],
                         'https://buckets.s3.amazonaws.com')