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.
2
4
commands.
3
5
"""
4
6
from os .path import exists , join
5
7
import os
6
8
import tarfile
7
9
import shutil
8
10
9
- from .test_utils import CliShedTestCase
11
+ from .test_utils import (
12
+ CliShedTestCase ,
13
+ TEST_REPOS_DIR ,
14
+ )
10
15
from planemo .io import shell
11
16
from planemo import git
12
17
@@ -40,12 +45,15 @@ def test_update_not_exists_update_only(self):
40
45
41
46
def test_update_with_check_diff (self ):
42
47
with self ._isolate_repo ("single_tool" ) as f :
48
+ self ._shed_create ()
49
+
50
+ self ._assert_shed_diff (diff = 0 )
51
+
43
52
upload_command = [
44
53
"shed_update" , "--force_repository_creation" , "--check_diff"
45
54
]
46
55
upload_command .extend (self ._shed_args ())
47
56
self ._check_exit_code (upload_command )
48
- upload_command .append ("--check_diff" )
49
57
50
58
# First time no difference.
51
59
r = self ._check_exit_code (upload_command )
@@ -55,15 +63,44 @@ def test_update_with_check_diff(self):
55
63
with open (join (f , "related_file" ), "w" ) as rf :
56
64
rf .write ("new_contents" )
57
65
66
+ self ._assert_shed_diff (diff = 1 )
67
+
58
68
# No assert there is no difference again.
59
69
r = self ._check_exit_code (upload_command )
60
70
assert "not different, skipping upload." not in r .output
61
71
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 :
64
100
upload_command = ["shed_update" , "--force_repository_creation" , "--skip_upload" ]
65
101
upload_command .extend (self ._shed_args ())
66
102
self ._check_exit_code (upload_command )
103
+ self ._verify_empty_repository (f )
67
104
68
105
def test_update_with_force_create (self ):
69
106
with self ._isolate_repo ("single_tool" ) as f :
@@ -290,6 +327,11 @@ def test_upload_with_double_dot(self):
290
327
],
291
328
not_contains = [])
292
329
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
+
293
335
def _verify_expansion (self , f , name = None ):
294
336
upload_command = ["shed_upload" , "--tar_only" ]
295
337
upload_command .extend (self ._shed_args ())
@@ -320,6 +362,10 @@ def _verify_single_uploaded(self, f, download_args=[]):
320
362
f , ["cat.xml" , "related_file" , "test-data/1.bed" ], download_args
321
363
)
322
364
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
+
323
369
def _verify_upload (self , f , download_files = [], download_args = []):
324
370
target = self ._download_repo (f , download_args )
325
371
for download_file in download_files :
@@ -371,7 +417,21 @@ def _untar(self, f, path, tarbomb=True):
371
417
return target
372
418
373
419
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
+
374
430
def assert_exists (path ):
431
+ """Assert supplied ``path`` exists.
432
+
433
+ Produces an informative AssertionError if it is does not.
434
+ """
375
435
dir_path = os .path .dirname (path )
376
436
msg = None
377
437
if not exists (dir_path ):
0 commit comments