File tree Expand file tree Collapse file tree 4 files changed +30
-33
lines changed Expand file tree Collapse file tree 4 files changed +30
-33
lines changed Original file line number Diff line number Diff line change 3131from tests .utils import spy
3232
3333from tests .remotes import (
34- _should_test_aws ,
3534 _should_test_gcp ,
3635 _should_test_hdfs ,
3736 _should_test_ssh ,
3837 Azure ,
3938 GDrive ,
39+ S3 ,
4040 OSS ,
4141 TEST_CONFIG ,
4242 TEST_SECTION ,
4343 TEST_GCP_CREDS_FILE ,
4444 TEST_GDRIVE_CLIENT_ID ,
4545 TEST_GDRIVE_CLIENT_SECRET ,
4646 TEST_REMOTE ,
47- get_aws_url ,
4847 get_gcp_url ,
4948 get_hdfs_url ,
5049 get_local_url ,
@@ -195,10 +194,10 @@ def test(self):
195194
196195class TestRemoteS3 (TestDataCloudBase ):
197196 def _should_test (self ):
198- return _should_test_aws ()
197+ return S3 . should_test ()
199198
200199 def _get_url (self ):
201- return get_aws_url ()
200+ return S3 . get_url ()
202201
203202 def _get_cloud_class (self ):
204203 return RemoteS3
@@ -469,10 +468,10 @@ def _test(self):
469468
470469class TestRemoteS3CLI (TestDataCloudCLIBase ):
471470 def _should_test (self ):
472- return _should_test_aws ()
471+ return S3 . should_test ()
473472
474473 def _test (self ):
475- url = get_aws_url ()
474+ url = S3 . get_url ()
476475
477476 self .main (["remote" , "add" , TEST_REMOTE , url ])
478477
Original file line number Diff line number Diff line change 3434from dvc .utils .stage import load_stage_file
3535from tests .basic_env import TestDvc
3636from tests .remotes import (
37- _should_test_aws ,
3837 _should_test_gcp ,
3938 _should_test_hdfs ,
4039 _should_test_ssh ,
4140 get_ssh_url ,
41+ S3 ,
4242 TEST_AWS_REPO_BUCKET ,
4343 TEST_GCP_REPO_BUCKET ,
4444)
@@ -954,7 +954,7 @@ def test(self, mock_prompt):
954954@pytest .mark .skipif (os .name == "nt" , reason = "temporarily disabled on windows" )
955955class TestReproExternalS3 (TestReproExternalBase ):
956956 def should_test (self ):
957- return _should_test_aws ()
957+ return S3 . should_test ()
958958
959959 @property
960960 def scheme (self ):
Original file line number Diff line number Diff line change 55from moto import mock_s3
66
77from dvc .remote .s3 import RemoteS3
8- from tests .remotes import get_aws_url
8+ from tests .remotes import S3
99
1010
1111# from https://github.com/spulec/moto/blob/v1.3.5/tests/test_s3/test_s3.py#L40
@@ -30,7 +30,7 @@ def wrapped(*args, **kwargs):
3030
3131
3232def _get_src_dst ():
33- base_info = RemoteS3 .path_cls (get_aws_url ())
33+ base_info = RemoteS3 .path_cls (S3 . get_url ())
3434 return base_info / "from" , base_info / "to"
3535
3636
Original file line number Diff line number Diff line change 4343TEST_GDRIVE_CLIENT_SECRET = "2fy_HyzSwkxkGzEken7hThXb"
4444
4545
46- def _should_test_aws ():
47- do_test = env2bool ("DVC_TEST_AWS" , undefined = None )
48- if do_test is not None :
49- return do_test
50-
51- if os .getenv ("AWS_ACCESS_KEY_ID" ) and os .getenv ("AWS_SECRET_ACCESS_KEY" ):
52- return True
53-
54- return False
55-
56-
5746def _should_test_gcp ():
5847 do_test = env2bool ("DVC_TEST_GCP" , undefined = None )
5948 if do_test is not None :
@@ -156,14 +145,6 @@ def get_hdfs_url():
156145 )
157146
158147
159- def get_aws_storagepath ():
160- return TEST_AWS_REPO_BUCKET + "/" + str (uuid .uuid4 ())
161-
162-
163- def get_aws_url ():
164- return "s3://" + get_aws_storagepath ()
165-
166-
167148def get_gcp_storagepath ():
168149 return TEST_GCP_REPO_BUCKET + "/" + str (uuid .uuid4 ())
169150
@@ -179,13 +160,30 @@ class Local:
179160
180161
181162class S3 :
182- should_test = staticmethod (_should_test_aws )
183- get_url = staticmethod (get_aws_url )
163+ @staticmethod
164+ def should_test ():
165+ do_test = env2bool ("DVC_TEST_AWS" , undefined = None )
166+ if do_test is not None :
167+ return do_test
168+
169+ if os .getenv ("AWS_ACCESS_KEY_ID" ) and os .getenv (
170+ "AWS_SECRET_ACCESS_KEY"
171+ ):
172+ return True
173+
174+ return False
175+
176+ @staticmethod
177+ def get_storagepath ():
178+ return TEST_AWS_REPO_BUCKET + "/" + str (uuid .uuid4 ())
179+
180+ @staticmethod
181+ def get_url ():
182+ return "s3://" + S3 .get_storagepath ()
184183
185184
186- class S3Mocked :
185+ class S3Mocked ( S3 ) :
187186 should_test = staticmethod (lambda : True )
188- get_url = staticmethod (get_aws_url )
189187
190188 @classmethod
191189 @contextmanager
You can’t perform that action at this time.
0 commit comments