##// END OF EJS Templates
artifacts: fixed some tests
marcink -
r3690:e633696c new-ui
parent child Browse files
Show More
@@ -21,6 +21,7 b' import os'
21 import pytest
21 import pytest
22
22
23 from rhodecode.lib.ext_json import json
23 from rhodecode.lib.ext_json import json
24 from rhodecode.model.db import Session, FileStore
24 from rhodecode.tests import TestController
25 from rhodecode.tests import TestController
25 from rhodecode.apps.file_store import utils, config_keys
26 from rhodecode.apps.file_store import utils, config_keys
26
27
@@ -46,9 +47,12 b' class TestFileStoreViews(TestController)'
46 ('abcde-0.exe', "1234567", True),
47 ('abcde-0.exe', "1234567", True),
47 ('abcde-0.jpg', "xxxxx", False),
48 ('abcde-0.jpg', "xxxxx", False),
48 ])
49 ])
49 def test_get_files_from_store(self, fid, content, exists, tmpdir):
50 def test_get_files_from_store(self, fid, content, exists, tmpdir, user_util):
50 self.log_user()
51 user = self.log_user()
52 user_id = user['user_id']
53 repo_id = user_util.create_repo().repo_id
51 store_path = self.app._pyramid_settings[config_keys.store_path]
54 store_path = self.app._pyramid_settings[config_keys.store_path]
55 store_uid = fid
52
56
53 if exists:
57 if exists:
54 status = 200
58 status = 200
@@ -58,17 +62,28 b' class TestFileStoreViews(TestController)'
58 f.write(content)
62 f.write(content)
59
63
60 with open(filesystem_file, 'rb') as f:
64 with open(filesystem_file, 'rb') as f:
61 fid, metadata = store.save_file(f, fid, extra_metadata={'filename': fid})
65 store_uid, metadata = store.save_file(f, fid, extra_metadata={'filename': fid})
66
67 entry = FileStore.create(
68 file_uid=store_uid, filename=metadata["filename"],
69 file_hash=metadata["sha256"], file_size=metadata["size"],
70 file_display_name='file_display_name',
71 file_description='repo artifact `{}`'.format(metadata["filename"]),
72 check_acl=True, user_id=user_id,
73 scope_repo_id=repo_id
74 )
75 Session().add(entry)
76 Session().commit()
62
77
63 else:
78 else:
64 status = 404
79 status = 404
65
80
66 response = self.app.get(route_path('download_file', fid=fid), status=status)
81 response = self.app.get(route_path('download_file', fid=store_uid), status=status)
67
82
68 if exists:
83 if exists:
69 assert response.text == content
84 assert response.text == content
70 file_store_path = os.path.dirname(store.resolve_name(fid, store_path)[1])
85 file_store_path = os.path.dirname(store.resolve_name(store_uid, store_path)[1])
71 metadata_file = os.path.join(file_store_path, fid + '.meta')
86 metadata_file = os.path.join(file_store_path, store_uid + '.meta')
72 assert os.path.exists(metadata_file)
87 assert os.path.exists(metadata_file)
73 with open(metadata_file, 'rb') as f:
88 with open(metadata_file, 'rb') as f:
74 json_data = json.loads(f.read())
89 json_data = json.loads(f.read())
General Comments 0
You need to be logged in to leave comments. Login now