@@ -61,7 +61,7 @@ async def test_validate_v1_path_root(self, provider):
6161
6262 assert wb_path_v1 == wb_path_v0
6363 assert wb_path_v1 .branch_name == default_branch_body ['name' ]
64- assert wb_path_v1 .commit_sha == None
64+ assert wb_path_v1 .commit_sha is None
6565
6666 @pytest .mark .asyncio
6767 @pytest .mark .aiohttpretty
@@ -77,8 +77,8 @@ async def test_validate_v1_path(self, provider, path, kind):
7777 default_branch_url = provider ._build_v1_repo_url ('main-branch' )
7878 aiohttpretty .register_json_uri ('GET' , default_branch_url , body = default_branch_body )
7979
80- dir_listing_body = test_fixtures ['root_dir_listing' ]
81- dir_listing_url = provider ._build_v1_repo_url ('src' , default_branch ) + '/'
80+ dir_listing_body = test_fixtures ['root_dir_listing' ]
81+ dir_listing_url = provider ._build_v1_repo_url ('src' , default_branch ) + '/'
8282 aiohttpretty .register_json_uri ('GET' , dir_listing_url , body = dir_listing_body )
8383
8484 try :
@@ -107,9 +107,9 @@ async def test_validate_v1_path(self, provider, path, kind):
107107 async def test_validate_v1_path_commit_sha (self , provider , arg_name , arg_val , attr_name ):
108108 test_fixtures = fixtures .validate_path
109109
110- dir_listing_body = test_fixtures ['root_dir_listing' ]
110+ dir_listing_body = test_fixtures ['root_dir_listing' ]
111111 base_commit = dir_listing_body ['node' ]
112- dir_listing_url = provider ._build_v1_repo_url ('src' , arg_val ) + '/'
112+ dir_listing_url = provider ._build_v1_repo_url ('src' , arg_val ) + '/'
113113 aiohttpretty .register_json_uri ('GET' , dir_listing_url , body = dir_listing_body )
114114
115115 path = '/foo-file.txt'
@@ -145,9 +145,9 @@ async def test_validate_v1_path_commit_sha(self, provider, arg_name, arg_val, at
145145 async def test_validate_v1_path_subfolder (self , provider ):
146146 test_fixtures = fixtures .validate_path
147147
148- dir_listing_body = test_fixtures ['subfolder_dir_listing' ]
148+ dir_listing_body = test_fixtures ['subfolder_dir_listing' ]
149149 base_commit = dir_listing_body ['node' ]
150- dir_listing_url = provider ._build_v1_repo_url ('src' , 'main-branch' , 'subfolder' ) + '/'
150+ dir_listing_url = provider ._build_v1_repo_url ('src' , 'main-branch' , 'subfolder' ) + '/'
151151 aiohttpretty .register_json_uri ('GET' , dir_listing_url , body = dir_listing_body )
152152
153153 path = '/subfolder/.gitkeep'
@@ -186,8 +186,8 @@ async def test_get_metadata_for_file(self, provider):
186186 path = BitbucketPath ('/foo-file.txt' , _ids = [(base_ref , 'develop' ), (base_ref , 'develop' )])
187187
188188 test_fixtures = fixtures .validate_path
189- dir_listing_body = test_fixtures ['root_dir_listing' ]
190- dir_listing_url = provider ._build_v1_repo_url ('src' , base_ref ) + '/'
189+ dir_listing_body = test_fixtures ['root_dir_listing' ]
190+ dir_listing_url = provider ._build_v1_repo_url ('src' , base_ref ) + '/'
191191 aiohttpretty .register_json_uri ('GET' , dir_listing_url , body = dir_listing_body )
192192
193193 result = await provider .metadata (path )
@@ -211,8 +211,8 @@ async def test_get_metadata_for_folder(self, provider):
211211 path = BitbucketPath ('/' , _ids = [(None , 'develop' )], folder = True )
212212
213213 test_fixtures = fixtures .validate_path
214- dir_listing_body = test_fixtures ['root_dir_listing' ]
215- dir_listing_url = provider ._build_v1_repo_url ('src' , 'develop' ) + '/'
214+ dir_listing_body = test_fixtures ['root_dir_listing' ]
215+ dir_listing_url = provider ._build_v1_repo_url ('src' , 'develop' ) + '/'
216216 aiohttpretty .register_json_uri ('GET' , dir_listing_url , body = dir_listing_body )
217217
218218 result = await provider .metadata (path )
@@ -229,8 +229,8 @@ async def test_get_metadata_for_file(self, provider):
229229 path = BitbucketPath ('/foo-file.txt' , _ids = [(base_ref , 'develop' ), (base_ref , 'develop' )])
230230
231231 test_fixtures = fixtures .validate_path
232- dir_listing_body = test_fixtures ['root_dir_listing' ]
233- dir_listing_url = provider ._build_v1_repo_url ('src' , base_ref ) + '/'
232+ dir_listing_body = test_fixtures ['root_dir_listing' ]
233+ dir_listing_url = provider ._build_v1_repo_url ('src' , base_ref ) + '/'
234234 aiohttpretty .register_json_uri ('GET' , dir_listing_url , body = dir_listing_body )
235235
236236 download_url = provider ._build_v1_repo_url ('raw' , path .commit_sha , * path .path_tuple ())
@@ -268,17 +268,38 @@ async def test_copy_to(self, provider):
268268 assert e .value .code == 501
269269
270270 def test_can_intra_move (self , provider ):
271- assert provider .can_intra_move (provider ) == False
271+ assert provider .can_intra_move (provider ) is False
272272
273273 def test_can_intra_copy (self , provider ):
274- assert provider .can_intra_copy (provider ) == False
274+ assert provider .can_intra_copy (provider ) is False
275275
276276
277277# leftover bits
278278class TestMisc :
279279
280+ @pytest .mark .asyncio
281+ async def test_construct_path (self , provider ):
282+ name = 'aaa-01-2.txt'
283+ subdir = 'plaster'
284+ full_path = '/{}/{}' .format (subdir , name )
285+ branch = 'master'
286+ commit_sha = '123abc456def'
287+
288+ path = BitbucketPath (full_path , _ids = [
289+ (commit_sha , branch ), (commit_sha , branch ), (commit_sha , branch )
290+ ])
291+
292+ metadata = BitbucketFileMetadata (fixtures .file_metadata , path , owner = fixtures .owner , repo = fixtures .repo )
293+ child_path = await provider .construct_path (path .parent , metadata )
294+ rev_metadata = await provider .revalidate_path (path .parent ,
295+ metadata .name , folder = metadata .is_folder )
296+
297+ assert child_path .full_path == path .full_path
298+ assert child_path == path
299+ assert child_path == rev_metadata
300+
280301 def test_can_duplicate_name (self , provider ):
281- assert provider .can_duplicate_names () == False
302+ assert provider .can_duplicate_names () is False
282303
283304 def test_path_from_metadata (self , provider ):
284305 name = 'aaa-01-2.txt'
@@ -292,7 +313,7 @@ def test_path_from_metadata(self, provider):
292313 ])
293314
294315 metadata = BitbucketFileMetadata (fixtures .file_metadata , path , owner = fixtures .owner , repo = fixtures .repo )
295- child_path = provider .path_from_metadata (path .parent , metadata )
316+ child_path = provider .path_from_metadata (path .parent , metadata )
296317
297318 assert child_path .full_path == path .full_path
298319 assert child_path == path
0 commit comments