Skip to content

Commit fe44afa

Browse files
committed
Allow files to be saved for runs in the created state
1 parent 439c809 commit fe44afa

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

simvue/run.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,6 @@ def save(self, filename, category, filetype=None, preserve_path=False, name=None
525525
self._error(INIT_MISSING)
526526
return False
527527

528-
if not self._active:
529-
self._error('Run is not active')
530-
return False
531-
532528
is_file = False
533529
if isinstance(filename, str):
534530
if not os.path.isfile(filename):
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 TestArtifactsCreatedState(unittest.TestCase):
14+
def test_artifact_code_created(self):
15+
"""
16+
Create a run & an artifact of type 'code' & check it can be downloaded for
17+
a run left in the created state
18+
"""
19+
run = Run()
20+
run.init(common.RUNNAME1, folder=common.FOLDER, running=False)
21+
22+
content = str(uuid.uuid4())
23+
with open(common.FILENAME1, 'w') as fh:
24+
fh.write(content)
25+
run.save(common.FILENAME1, 'code')
26+
27+
shutil.rmtree('./test', ignore_errors=True)
28+
os.mkdir('./test')
29+
30+
client = Client()
31+
client.get_artifact_as_file(common.RUNNAME1, common.FILENAME1, './test')
32+
33+
self.assertTrue(filecmp.cmp(common.FILENAME1, './test/%s' % common.FILENAME1))
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.FILENAME1)
40+
41+
if __name__ == '__main__':
42+
unittest.main()

0 commit comments

Comments
 (0)