Show More
@@ -21,6 +21,7 b' import os' | |||
|
21 | 21 | import pytest |
|
22 | 22 | |
|
23 | 23 | from rhodecode.lib.ext_json import json |
|
24 | from rhodecode.model.db import Session, FileStore | |
|
24 | 25 | from rhodecode.tests import TestController |
|
25 | 26 | from rhodecode.apps.file_store import utils, config_keys |
|
26 | 27 | |
@@ -46,9 +47,12 b' class TestFileStoreViews(TestController)' | |||
|
46 | 47 | ('abcde-0.exe', "1234567", True), |
|
47 | 48 | ('abcde-0.jpg', "xxxxx", False), |
|
48 | 49 | ]) |
|
49 | def test_get_files_from_store(self, fid, content, exists, tmpdir): | |
|
50 | self.log_user() | |
|
50 | def test_get_files_from_store(self, fid, content, exists, tmpdir, user_util): | |
|
51 | user = self.log_user() | |
|
52 | user_id = user['user_id'] | |
|
53 | repo_id = user_util.create_repo().repo_id | |
|
51 | 54 | store_path = self.app._pyramid_settings[config_keys.store_path] |
|
55 | store_uid = fid | |
|
52 | 56 | |
|
53 | 57 | if exists: |
|
54 | 58 | status = 200 |
@@ -58,17 +62,28 b' class TestFileStoreViews(TestController)' | |||
|
58 | 62 | f.write(content) |
|
59 | 63 | |
|
60 | 64 | with open(filesystem_file, 'rb') as f: |
|
61 |
|
|
|
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 | 78 | else: |
|
64 | 79 | status = 404 |
|
65 | 80 | |
|
66 |
response = self.app.get(route_path('download_file', fid= |
|
|
81 | response = self.app.get(route_path('download_file', fid=store_uid), status=status) | |
|
67 | 82 | |
|
68 | 83 | if exists: |
|
69 | 84 | assert response.text == content |
|
70 |
file_store_path = os.path.dirname(store.resolve_name( |
|
|
71 |
metadata_file = os.path.join(file_store_path, |
|
|
85 | file_store_path = os.path.dirname(store.resolve_name(store_uid, store_path)[1]) | |
|
86 | metadata_file = os.path.join(file_store_path, store_uid + '.meta') | |
|
72 | 87 | assert os.path.exists(metadata_file) |
|
73 | 88 | with open(metadata_file, 'rb') as f: |
|
74 | 89 | json_data = json.loads(f.read()) |
General Comments 0
You need to be logged in to leave comments.
Login now