2020# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2121
2222from __future__ import division
23+ from past .utils import old_div
2324from builtins import object
2425import pytest # noqa
2526
@@ -37,6 +38,79 @@ def download(self, *args):
3738 main ("omego" , args = args , items = [("download" , DownloadCommand )])
3839
3940
41+ class TestDownloadJenkins (Downloader ):
42+
43+ def setup_class (self ):
44+ self .artifact = 'java'
45+ self .branch = 'OMERO-build'
46+ self .ice = '3.6'
47+
48+ @pytest .mark .skipif (True , reason = 'URL to be updated' )
49+ def testDownloadNoUnzip (self , tmpdir ):
50+ with tmpdir .as_cwd ():
51+ self .download ('--skipunzip' , '--branch' , self .branch ,
52+ '--ice' , self .ice )
53+ files = tmpdir .listdir ()
54+ assert len (files ) == 1
55+
56+ @pytest .mark .skipif (True , reason = 'URL to be updated' )
57+ def testDownloadUnzip (self , tmpdir ):
58+ with tmpdir .as_cwd ():
59+ self .download ('--branch' , self .branch , '--ice' , self .ice )
60+ files = tmpdir .listdir ()
61+ assert len (files ) == 2
62+
63+ @pytest .mark .skipif (True , reason = 'URL to be updated' )
64+ def testDownloadUnzipDir (self , tmpdir ):
65+ with tmpdir .as_cwd ():
66+ self .download ('--unzipdir' , 'OMERO.java' , '--branch' , self .branch ,
67+ '--ice' , self .ice )
68+ expected = old_div (tmpdir , 'OMERO.java' )
69+ assert expected .exists ()
70+ assert expected .isdir ()
71+
72+ @pytest .mark .skipif (True , reason = 'URL to be updated' )
73+ def testDownloadSym (self , tmpdir ):
74+ with tmpdir .as_cwd ():
75+ self .download ('--branch' , self .branch , '--ice' , self .ice ,
76+ '--sym' , 'auto' )
77+ files = tmpdir .listdir ()
78+ assert len (files ) == 3
79+
80+ expected = old_div (tmpdir , 'OMERO.java' )
81+ assert expected .exists ()
82+ assert expected .isdir ()
83+
84+ # Part two, if an artifact already exists and is unzipped check
85+ # that a new symlink is created if necessary
86+ self .download ('--branch' , self .branch , '--ice' , self .ice ,
87+ '--sym' , 'custom.sym' )
88+ files2 = tmpdir .listdir ()
89+ files2diff = set (files2 ).symmetric_difference (files )
90+ assert len (files2diff ) == 1
91+ sym2 = files2diff .pop ()
92+ assert sym2 == (old_div (tmpdir , 'custom.sym' ))
93+ assert sym2 .isdir ()
94+
95+ @pytest .mark .skipif (True , reason = 'URL to be updated' )
96+ def testDownloadBuildNumber (self ):
97+ # Old Jenkins artifacts are deleted so we can't download.
98+ # Instead assert that an AttributeError is raised.
99+ # This is not ideal since this error could occur for other reasons.
100+ branch = self .branch + ':600'
101+ with pytest .raises (AttributeError ) as exc :
102+ self .download ('--branch' , branch , '--ice' , self .ice )
103+ assert 'No artifacts' in exc .value .args [0 ]
104+
105+ def testDownloadList (self , tmpdir ):
106+ self .artifact = ''
107+ self .branch = 'latest'
108+ with tmpdir .as_cwd ():
109+ self .download ('--branch' , self .branch )
110+ files = tmpdir .listdir ()
111+ assert len (files ) == 0
112+
113+
40114class TestDownloadRelease (Downloader ):
41115
42116 def setup_class (self ):
@@ -52,3 +126,19 @@ def testDownloadRelease(self, tmpdir):
52126 def testDownloadNonExistingArtifact (self ):
53127 with pytest .raises (AttributeError ):
54128 self .download ('-n' , '--release' , '5.3' , '--ice' , '3.3' )
129+
130+
131+ class TestDownloadBioFormats (Downloader ):
132+
133+ def setup_class (self ):
134+ self .branch = 'BIOFORMATS-build'
135+
136+ @pytest .mark .skipif (True , reason = 'URL to be updated' )
137+ def testDownloadJar (self , tmpdir ):
138+ self .artifact = 'formats-api'
139+ with tmpdir .as_cwd ():
140+ self .download ('--branch' , self .branch )
141+ files = tmpdir .listdir ()
142+ assert len (files ) == 1
143+ assert files [0 ].basename .endswith (".jar" )
144+ assert files [0 ].basename .startswith ('formats-api' )
0 commit comments