1- """ Integration tests for shed_upload, shed_download, and shed_create
1+ """Integration tests for shed contents commands.
2+
3+ Specifically, tests for shed_upload, shed_download, and shed_create.
24commands.
35"""
46from os .path import exists , join
57import os
68import tarfile
79import shutil
810
9- from .test_utils import CliShedTestCase
11+ from .test_utils import (
12+ CliShedTestCase ,
13+ TEST_REPOS_DIR ,
14+ )
1015from planemo .io import shell
1116from planemo import git
1217
@@ -40,12 +45,15 @@ def test_update_not_exists_update_only(self):
4045
4146 def test_update_with_check_diff (self ):
4247 with self ._isolate_repo ("single_tool" ) as f :
48+ self ._shed_create ()
49+
50+ self ._assert_shed_diff (diff = 0 )
51+
4352 upload_command = [
4453 "shed_update" , "--force_repository_creation" , "--check_diff"
4554 ]
4655 upload_command .extend (self ._shed_args ())
4756 self ._check_exit_code (upload_command )
48- upload_command .append ("--check_diff" )
4957
5058 # First time no difference.
5159 r = self ._check_exit_code (upload_command )
@@ -55,15 +63,44 @@ def test_update_with_check_diff(self):
5563 with open (join (f , "related_file" ), "w" ) as rf :
5664 rf .write ("new_contents" )
5765
66+ self ._assert_shed_diff (diff = 1 )
67+
5868 # No assert there is no difference again.
5969 r = self ._check_exit_code (upload_command )
6070 assert "not different, skipping upload." not in r .output
6171
62- def test_update_metadata_only (self ):
63- with self ._isolate_repo ("single_tool" ):
72+ self ._assert_shed_diff (diff = 0 )
73+
74+ def test_update_with_check_diff_package (self ):
75+ with self ._isolate_repo ("package_1" ) as f :
76+ self ._shed_create ()
77+
78+ self ._assert_shed_diff (diff = 0 )
79+ upload_command = [
80+ "shed_update" , "--force_repository_creation" , "--check_diff"
81+ ]
82+ upload_command .extend (self ._shed_args ())
83+ self ._check_exit_code (upload_command )
84+
85+ # First time no difference.
86+ r = self ._check_exit_code (upload_command )
87+ assert "not different, skipping upload." in r .output
88+
89+ update_package_1 (f )
90+ self ._assert_shed_diff (diff = 1 )
91+
92+ # No assert there is no difference again.
93+ r = self ._check_exit_code (upload_command )
94+ assert "not different, skipping upload." not in r .output
95+
96+ self ._assert_shed_diff (diff = 0 )
97+
98+ def test_update_with_force_create_metadata_only (self ):
99+ with self ._isolate_repo ("single_tool" ) as f :
64100 upload_command = ["shed_update" , "--force_repository_creation" , "--skip_upload" ]
65101 upload_command .extend (self ._shed_args ())
66102 self ._check_exit_code (upload_command )
103+ self ._verify_empty_repository (f )
67104
68105 def test_update_with_force_create (self ):
69106 with self ._isolate_repo ("single_tool" ) as f :
@@ -290,6 +327,11 @@ def test_upload_with_double_dot(self):
290327 ],
291328 not_contains = [])
292329
330+ def _assert_shed_diff (self , diff = 1 ):
331+ shed_diff_command = ["shed_diff" ]
332+ shed_diff_command .extend (self ._shed_args ())
333+ self ._check_exit_code (shed_diff_command , exit_code = diff )
334+
293335 def _verify_expansion (self , f , name = None ):
294336 upload_command = ["shed_upload" , "--tar_only" ]
295337 upload_command .extend (self ._shed_args ())
@@ -320,6 +362,10 @@ def _verify_single_uploaded(self, f, download_args=[]):
320362 f , ["cat.xml" , "related_file" , "test-data/1.bed" ], download_args
321363 )
322364
365+ def _verify_empty_repository (self , f , download_args = []):
366+ target = self ._download_repo (f , download_args )
367+ assert len (os .listdir (target )) == 0
368+
323369 def _verify_upload (self , f , download_files = [], download_args = []):
324370 target = self ._download_repo (f , download_args )
325371 for download_file in download_files :
@@ -371,7 +417,21 @@ def _untar(self, f, path, tarbomb=True):
371417 return target
372418
373419
420+ def update_package_1 (f ):
421+ """Update tool dependencies file for package_1."""
422+ changed_xml = join (
423+ TEST_REPOS_DIR ,
424+ "package_1_changed" ,
425+ "tool_dependencies.xml"
426+ )
427+ shutil .copyfile (changed_xml , join (f , "tool_dependencies.xml" ))
428+
429+
374430def assert_exists (path ):
431+ """Assert supplied ``path`` exists.
432+
433+ Produces an informative AssertionError if it is does not.
434+ """
375435 dir_path = os .path .dirname (path )
376436 msg = None
377437 if not exists (dir_path ):
0 commit comments