File tree Expand file tree Collapse file tree 2 files changed +79
-0
lines changed Expand file tree Collapse file tree 2 files changed +79
-0
lines changed Original file line number Diff line number Diff line change
1
+ import configparser
2
+ import filecmp
3
+ import os
4
+ import shutil
5
+ import time
6
+ import unittest
7
+ import uuid
8
+ from simvue import Run , Client
9
+ from simvue .sender import sender
10
+
11
+ import common
12
+
13
+ class TestArtifactsCreated (unittest .TestCase ):
14
+ def test_artifact_input_created (self ):
15
+ """
16
+ Create a run & an artifact of type 'input' & check it can be downloaded
17
+ for runs in the created state
18
+ """
19
+ run = Run ()
20
+ run .init (common .RUNNAME2 , folder = common .FOLDER , running = False )
21
+
22
+ content = str (uuid .uuid4 ())
23
+ with open (common .FILENAME2 , 'w' ) as fh :
24
+ fh .write (content )
25
+ run .save (common .FILENAME2 , 'input' )
26
+
27
+ shutil .rmtree ('./test' , ignore_errors = True )
28
+ os .mkdir ('./test' )
29
+
30
+ client = Client ()
31
+ client .get_artifact_as_file (common .RUNNAME2 , common .FILENAME2 , './test' )
32
+
33
+ self .assertTrue (filecmp .cmp (common .FILENAME2 , './test/%s' % common .FILENAME2 ))
34
+
35
+ runs = client .delete_runs (common .FOLDER )
36
+ self .assertEqual (len (runs ), 1 )
37
+
38
+ shutil .rmtree ('./test' , ignore_errors = True )
39
+ os .remove (common .FILENAME2 )
40
+
41
+ if __name__ == '__main__' :
42
+ unittest .main ()
Original file line number Diff line number Diff line change
1
+ import configparser
2
+ import filecmp
3
+ import os
4
+ import shutil
5
+ import time
6
+ import unittest
7
+ import uuid
8
+ from simvue import Run , Client
9
+
10
+ import common
11
+
12
+ class TestArtifactsOutputCreated (unittest .TestCase ):
13
+ def test_artifact_output_created (self ):
14
+ """
15
+ Create a run in the created state and check that an output file
16
+ cannot be saved.
17
+ """
18
+ run = Run ()
19
+ run .init (common .RUNNAME3 , folder = common .FOLDER , running = False )
20
+
21
+ content = str (uuid .uuid4 ())
22
+ with open (common .FILENAME3 , 'w' ) as fh :
23
+ fh .write (content )
24
+
25
+ with self .assertRaises (Exception ) as context :
26
+ run .save (common .FILENAME3 , 'output' )
27
+
28
+ self .assertTrue ('Cannot upload output files for runs in the created state' in str (context .exception ))
29
+
30
+ client = Client ()
31
+ runs = client .delete_runs (common .FOLDER )
32
+ self .assertEqual (len (runs ), 1 )
33
+
34
+ os .remove (common .FILENAME3 )
35
+
36
+ if __name__ == '__main__' :
37
+ unittest .main ()
You can’t perform that action at this time.
0 commit comments